From d5bea103aa5254627406ac2f629f7e42dace914e 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 | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/pkg/link/link.go b/pkg/link/link.go index 3635119..d97fe63 100644 --- a/pkg/link/link.go +++ b/pkg/link/link.go @@ -233,7 +233,17 @@ 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() + existingSuffixes := make(map[string]bool) + for _, existingSuffix := range dnsSuffixes { + existingSuffixes[existingSuffix] = true + } + + for _, newSuffix := range cfg.F5Config.Object.DNSSuffix { + if !existingSuffixes[newSuffix] { + dnsSuffixes = append(dnsSuffixes, newSuffix) + } + } l.resolvHandler.SetSuffixes(dnsSuffixes) }