From 95470c3448f0a9d9eb98906fe24ccc1c5df1bbab Mon Sep 17 00:00:00 2001 From: David Anderson Date: Thu, 1 Apr 2021 23:04:23 -0700 Subject: [PATCH] net/dns: remove Cleanup manager parameter. It's only use to skip some optional initialization during cleanup, but that work is very minor anyway, and about to change drastically. Signed-off-by: David Anderson --- net/dns/config.go | 3 --- net/dns/manager.go | 1 - net/dns/manager_linux.go | 12 ++---------- net/dns/noop.go | 17 ----------------- 4 files changed, 2 insertions(+), 31 deletions(-) delete mode 100644 net/dns/noop.go diff --git a/net/dns/config.go b/net/dns/config.go index e89eda86e..884d9284c 100644 --- a/net/dns/config.go +++ b/net/dns/config.go @@ -63,7 +63,4 @@ type ManagerConfig struct { Logf logger.Logf // InterfaceName is the name of the interface with which DNS settings should be associated. InterfaceName string - // Cleanup indicates that the manager is created for cleanup only. - // A no-op manager will be instantiated if the system needs no cleanup. - Cleanup bool } diff --git a/net/dns/manager.go b/net/dns/manager.go index 6e6d4cd92..60a790bb0 100644 --- a/net/dns/manager.go +++ b/net/dns/manager.go @@ -94,7 +94,6 @@ func Cleanup(logf logger.Logf, interfaceName string) { mconfig := ManagerConfig{ Logf: logf, InterfaceName: interfaceName, - Cleanup: true, } dns := NewManager(mconfig) if err := dns.Down(); err != nil { diff --git a/net/dns/manager_linux.go b/net/dns/manager_linux.go index 6f995d4bf..51841219c 100644 --- a/net/dns/manager_linux.go +++ b/net/dns/manager_linux.go @@ -7,17 +7,9 @@ func newManager(mconfig ManagerConfig) managerImpl { switch { case isResolvedActive(): - if mconfig.Cleanup { - return newNoopManager(mconfig) - } else { - return newResolvedManager(mconfig) - } + return newResolvedManager(mconfig) case isNMActive(): - if mconfig.Cleanup { - return newNoopManager(mconfig) - } else { - return newNMManager(mconfig) - } + return newNMManager(mconfig) case isResolvconfActive(): return newResolvconfManager(mconfig) default: diff --git a/net/dns/noop.go b/net/dns/noop.go deleted file mode 100644 index 35c07a232..000000000 --- a/net/dns/noop.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright (c) 2020 Tailscale Inc & AUTHORS All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package dns - -type noopManager struct{} - -// Up implements managerImpl. -func (m noopManager) Up(Config) error { return nil } - -// Down implements managerImpl. -func (m noopManager) Down() error { return nil } - -func newNoopManager(mconfig ManagerConfig) managerImpl { - return noopManager{} -}