Skip to content

Commit d5bea10

Browse files
committed
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
1 parent beb33bb commit d5bea10

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

pkg/link/link.go

+11-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,17 @@ func (l *vpnLink) configureDNS(cfg *config.Config) error {
233233

234234
if len(cfg.DNS) > 0 && !l.resolvHandler.IsResolve() {
235235
// combine local network search with VPN gateway search
236-
dnsSuffixes = append(l.resolvHandler.GetOriginalSuffixes(), cfg.F5Config.Object.DNSSuffix...)
236+
dnsSuffixes = l.resolvHandler.GetOriginalSuffixes()
237+
existingSuffixes := make(map[string]bool)
238+
for _, existingSuffix := range dnsSuffixes {
239+
existingSuffixes[existingSuffix] = true
240+
}
241+
242+
for _, newSuffix := range cfg.F5Config.Object.DNSSuffix {
243+
if !existingSuffixes[newSuffix] {
244+
dnsSuffixes = append(dnsSuffixes, newSuffix)
245+
}
246+
}
237247
l.resolvHandler.SetSuffixes(dnsSuffixes)
238248
}
239249

0 commit comments

Comments
 (0)