wgengine: move DNS configuration out of wgengine/router.
Signed-off-by: David Anderson <danderson@tailscale.com>
This commit is contained in:
committed by
Dave Anderson
parent
7183e1f052
commit
4c61ebacf4
+4
-3
@@ -33,11 +33,11 @@ type Manager struct {
|
||||
}
|
||||
|
||||
// NewManagers created a new manager from the given config.
|
||||
func NewManager(logf logger.Logf, interfaceName string) *Manager {
|
||||
func NewManager(logf logger.Logf, oscfg OSConfigurator) *Manager {
|
||||
logf = logger.WithPrefix(logf, "dns: ")
|
||||
m := &Manager{
|
||||
logf: logf,
|
||||
impl: newManager(logf, interfaceName),
|
||||
impl: oscfg,
|
||||
}
|
||||
|
||||
m.logf("using %T", m.impl)
|
||||
@@ -81,7 +81,8 @@ func (m *Manager) Down() error {
|
||||
// in case the Tailscale daemon terminated without closing the router.
|
||||
// No other state needs to be instantiated before this runs.
|
||||
func Cleanup(logf logger.Logf, interfaceName string) {
|
||||
dns := NewManager(logf, interfaceName)
|
||||
oscfg := NewOSConfigurator(logf, interfaceName)
|
||||
dns := NewManager(logf, oscfg)
|
||||
if err := dns.Down(); err != nil {
|
||||
logf("dns down: %v", err)
|
||||
}
|
||||
|
||||
@@ -8,9 +8,9 @@ package dns
|
||||
|
||||
import "tailscale.com/types/logger"
|
||||
|
||||
func newManager(logger.Logf, string) OSConfigurator {
|
||||
func NewOSConfigurator(logger.Logf, string) OSConfigurator {
|
||||
// TODO(dmytro): on darwin, we should use a macOS-specific method such as scutil.
|
||||
// This is currently not implemented. Editing /etc/resolv.conf does not work,
|
||||
// as most applications use the system resolver, which disregards it.
|
||||
return newNoopManager()
|
||||
return NewNoopManager()
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ package dns
|
||||
|
||||
import "tailscale.com/types/logger"
|
||||
|
||||
func newManager(logf logger.Logf, _ string) OSConfigurator {
|
||||
func NewOSConfigurator(logf logger.Logf, _ string) OSConfigurator {
|
||||
switch {
|
||||
case isResolvconfActive():
|
||||
return newResolvconfManager(logf)
|
||||
|
||||
@@ -6,7 +6,7 @@ package dns
|
||||
|
||||
import "tailscale.com/types/logger"
|
||||
|
||||
func newManager(logf logger.Logf, interfaceName string) OSConfigurator {
|
||||
func NewOSConfigurator(logf logger.Logf, interfaceName string) OSConfigurator {
|
||||
switch {
|
||||
// TODO: rework NetworkManager and resolved support.
|
||||
// case isResolvedActive():
|
||||
|
||||
@@ -6,6 +6,6 @@ package dns
|
||||
|
||||
import "tailscale.com/types/logger"
|
||||
|
||||
func newManager(logger.Logf, string) OSConfigurator {
|
||||
func NewOSConfigurator(logger.Logf, string) OSConfigurator {
|
||||
return newDirectManager()
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ type windowsManager struct {
|
||||
guid string
|
||||
}
|
||||
|
||||
func newManager(logf logger.Logf, interfaceName string) OSConfigurator {
|
||||
func NewOSConfigurator(logf logger.Logf, interfaceName string) OSConfigurator {
|
||||
return windowsManager{
|
||||
logf: logf,
|
||||
guid: interfaceName,
|
||||
|
||||
+1
-3
@@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style
|
||||
// license that can be found in the LICENSE file.
|
||||
|
||||
// +build !linux,!freebsd,!openbsd,!windows
|
||||
|
||||
package dns
|
||||
|
||||
type noopManager struct{}
|
||||
@@ -12,6 +10,6 @@ func (m noopManager) Set(OSConfig) error { return nil }
|
||||
func (m noopManager) RoutingMode() RoutingMode { return RoutingModeNone }
|
||||
func (m noopManager) Close() error { return nil }
|
||||
|
||||
func newNoopManager() noopManager {
|
||||
func NewNoopManager() noopManager {
|
||||
return noopManager{}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user