@ -10,12 +10,15 @@ import (
"errors"
"errors"
"fmt"
"fmt"
"os"
"os"
"strings"
"sync"
"time"
"time"
"github.com/godbus/dbus/v5"
"github.com/godbus/dbus/v5"
"tailscale.com/health"
"tailscale.com/health"
"tailscale.com/net/netaddr"
"tailscale.com/net/netaddr"
"tailscale.com/types/logger"
"tailscale.com/types/logger"
"tailscale.com/util/clientmetric"
"tailscale.com/util/cmpver"
"tailscale.com/util/cmpver"
)
)
@ -27,6 +30,8 @@ func (kv kv) String() string {
return fmt . Sprintf ( "%s=%s" , kv . k , kv . v )
return fmt . Sprintf ( "%s=%s" , kv . k , kv . v )
}
}
var publishOnce sync . Once
func NewOSConfigurator ( logf logger . Logf , interfaceName string ) ( ret OSConfigurator , err error ) {
func NewOSConfigurator ( logf logger . Logf , interfaceName string ) ( ret OSConfigurator , err error ) {
env := newOSConfigEnv {
env := newOSConfigEnv {
fs : directFS { } ,
fs : directFS { } ,
@ -40,6 +45,12 @@ func NewOSConfigurator(logf logger.Logf, interfaceName string) (ret OSConfigurat
if err != nil {
if err != nil {
return nil , err
return nil , err
}
}
publishOnce . Do ( func ( ) {
sanitizedMode := strings . ReplaceAll ( mode , "-" , "_" )
m := clientmetric . NewGauge ( fmt . Sprintf ( "dns_manager_linux_mode_%s" , sanitizedMode ) )
m . Set ( 1 )
} )
logf ( "dns: using %q mode" , mode )
switch mode {
switch mode {
case "direct" :
case "direct" :
return newDirectManagerOnFS ( logf , env . fs ) , nil
return newDirectManagerOnFS ( logf , env . fs ) , nil