From 6934ac9de6e7e2088a753f7b83b2b85105473863 Mon Sep 17 00:00:00 2001 From: Fabian Wiesel Date: Fri, 22 Oct 2021 12:22:20 +0200 Subject: [PATCH] Avoid duplicate search entries More a stilistic nicety. If we get a search suffix passed, which is already part of the local configuration, it will be duplicated. The change avoids that --- pkg/link/link.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/pkg/link/link.go b/pkg/link/link.go index 3635119..4f1d82e 100644 --- a/pkg/link/link.go +++ b/pkg/link/link.go @@ -233,7 +233,20 @@ func (l *vpnLink) configureDNS(cfg *config.Config) error { if len(cfg.DNS) > 0 && !l.resolvHandler.IsResolve() { // combine local network search with VPN gateway search - dnsSuffixes = append(l.resolvHandler.GetOriginalSuffixes(), cfg.F5Config.Object.DNSSuffix...) + dnsSuffixes = l.resolvHandler.GetOriginalSuffixes() + for _, newSuffix := range cfg.F5Config.Object.DNSSuffix { + found := false + for _, existingSuffix := range l.resolvHandler.GetOriginalSuffixes() { + if newSuffix == existingSuffix { + found = true + break + } + } + + if !found { + dnsSuffixes = append(dnsSuffixes, newSuffix) + } + } l.resolvHandler.SetSuffixes(dnsSuffixes) }