Skip to content

Commit

Permalink
fix wrongly updated comments on DNSSetting export
Browse files Browse the repository at this point in the history
  • Loading branch information
pascal-fischer committed Dec 15, 2023
1 parent d08ef29 commit 077d0b9
Show file tree
Hide file tree
Showing 11 changed files with 31 additions and 31 deletions.
10 changes: 5 additions & 5 deletions client/internal/dns/file_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func (f *fileConfigurator) applyDNSConfig(config HostDNSConfig) error {
return fmt.Errorf("unable to configure DNS for this peer using file manager without a Primary nameserver group. Restoring the original file return err: %s", err)
}
}
return fmt.Errorf("unable to configure DNS for this peer using file manager without a nameserver group with all Domains configured")
return fmt.Errorf("unable to configure DNS for this peer using file manager without a nameserver group with all domains configured")
}

if !backupFileExist {
Expand Down Expand Up @@ -83,7 +83,7 @@ func (f *fileConfigurator) applyDNSConfig(config HostDNSConfig) error {
return fmt.Errorf("got an creating resolver file %s. Error: %s", defaultResolvConfPath, err)
}

log.Infof("created a NetBird managed %s file with your DNS settings. Added %d search Domains. Search list: %s", defaultResolvConfPath, len(searchDomainList), searchDomainList)
log.Infof("created a NetBird managed %s file with your DNS settings. Added %d search domains. Search list: %s", defaultResolvConfPath, len(searchDomainList), searchDomainList)
return nil
}

Expand Down Expand Up @@ -177,7 +177,7 @@ func originalDNSConfigs(resolvconfFile string) (searchDomains, nameServers, othe
continue
}

if strings.HasPrefix(line, "Domain") {
if strings.HasPrefix(line, "domain") {
continue
}

Expand Down Expand Up @@ -233,15 +233,15 @@ func validateAndFillSearchDomains(initialLineChars int, s *[]string, vs []string
tmpCharsNumber := initialLineChars + 1 + len(sd)
if tmpCharsNumber > fileMaxLineCharsLimit {
// lets log all skipped Domains
log.Infof("search list line is larger than %d characters. Skipping append of %s Domain", fileMaxLineCharsLimit, sd)
log.Infof("search list line is larger than %d characters. Skipping append of %s domain", fileMaxLineCharsLimit, sd)
continue
}

initialLineChars = tmpCharsNumber

if len(*s) >= fileMaxNumberOfSearchDomains {
// lets log all skipped Domains
log.Infof("already appended %d Domains to search list. Skipping append of %s Domain", fileMaxNumberOfSearchDomains, sd)
log.Infof("already appended %d domains to search list. Skipping append of %s domain", fileMaxNumberOfSearchDomains, sd)
continue
}
*s = append(*s, sd)
Expand Down
10 changes: 5 additions & 5 deletions client/internal/dns/file_linux_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ func Test_mergeSearchDomains(t *testing.T) {
originDomains := []string{"a", "b"}
mergedDomains := mergeSearchDomains(searchDomains, originDomains)
if len(mergedDomains) != 4 {
t.Errorf("invalid len of result Domains: %d, want: %d", len(mergedDomains), 4)
t.Errorf("invalid len of result domains: %d, want: %d", len(mergedDomains), 4)
}
}

Expand All @@ -19,7 +19,7 @@ func Test_mergeSearchTooMuchDomains(t *testing.T) {
originDomains := []string{"h", "i"}
mergedDomains := mergeSearchDomains(searchDomains, originDomains)
if len(mergedDomains) != 6 {
t.Errorf("invalid len of result Domains: %d, want: %d", len(mergedDomains), 6)
t.Errorf("invalid len of result domains: %d, want: %d", len(mergedDomains), 6)
}
}

Expand All @@ -28,7 +28,7 @@ func Test_mergeSearchTooMuchDomainsInOrigin(t *testing.T) {
originDomains := []string{"c", "d", "e", "f", "g"}
mergedDomains := mergeSearchDomains(searchDomains, originDomains)
if len(mergedDomains) != 6 {
t.Errorf("invalid len of result Domains: %d, want: %d", len(mergedDomains), 6)
t.Errorf("invalid len of result domains: %d, want: %d", len(mergedDomains), 6)
}
}

Expand All @@ -37,15 +37,15 @@ func Test_mergeSearchTooLongDomain(t *testing.T) {
originDomains := []string{"b"}
mergedDomains := mergeSearchDomains(searchDomains, originDomains)
if len(mergedDomains) != 1 {
t.Errorf("invalid len of result Domains: %d, want: %d", len(mergedDomains), 1)
t.Errorf("invalid len of result domains: %d, want: %d", len(mergedDomains), 1)
}

searchDomains = []string{"b"}
originDomains = []string{getLongLine()}

mergedDomains = mergeSearchDomains(searchDomains, originDomains)
if len(mergedDomains) != 1 {
t.Errorf("invalid len of result Domains: %d, want: %d", len(mergedDomains), 1)
t.Errorf("invalid len of result domains: %d, want: %d", len(mergedDomains), 1)
}
}

Expand Down
12 changes: 6 additions & 6 deletions client/internal/dns/host_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (s *systemConfigurator) applyDNSConfig(config HostDNSConfig) error {
if len(matchDomains) != 0 {
err = s.addMatchDomains(matchKey, strings.Join(matchDomains, " "), config.ServerIP, config.ServerPort)
} else {
log.Infof("removing match Domains from the system")
log.Infof("removing match domains from the system")
err = s.removeKeyFromSystemConfig(matchKey)
}
if err != nil {
Expand All @@ -92,7 +92,7 @@ func (s *systemConfigurator) applyDNSConfig(config HostDNSConfig) error {
if len(searchDomains) != 0 {
err = s.addSearchDomains(searchKey, strings.Join(searchDomains, " "), config.ServerIP, config.ServerPort)
} else {
log.Infof("removing search Domains from the system")
log.Infof("removing search domains from the system")
err = s.removeKeyFromSystemConfig(searchKey)
}
if err != nil {
Expand All @@ -110,7 +110,7 @@ func (s *systemConfigurator) restoreHostDNS() error {
if strings.Contains(key, matchSuffix) {
keyType = "match"
}
log.Infof("removing %s Domains from system", keyType)
log.Infof("removing %s domains from system", keyType)
}
if s.primaryServiceID != "" {
lines += buildRemoveKeyOperation(getKeyWithInput(primaryServiceSetupKeyFormat, s.primaryServiceID))
Expand Down Expand Up @@ -143,7 +143,7 @@ func (s *systemConfigurator) addSearchDomains(key, domains string, ip string, po
return err
}

log.Infof("added %d search Domains to the state. Domain list: %s", len(strings.Split(domains, " ")), domains)
log.Infof("added %d search domains to the state. Domain list: %s", len(strings.Split(domains, " ")), domains)

s.createdKeys[key] = struct{}{}

Expand All @@ -156,7 +156,7 @@ func (s *systemConfigurator) addMatchDomains(key, domains, dnsServer string, por
return err
}

log.Infof("added %d match Domains to the state. Domain list: %s", len(strings.Split(domains, " ")), domains)
log.Infof("added %d match domains to the state. Domain list: %s", len(strings.Split(domains, " ")), domains)

s.createdKeys[key] = struct{}{}

Expand All @@ -178,7 +178,7 @@ func (s *systemConfigurator) addDNSState(state, domains, dnsServer string, port

_, err := runSystemConfigCommand(stdinCommands)
if err != nil {
return fmt.Errorf("got error while applying state for Domains %s, error: %s", domains, err)
return fmt.Errorf("got error while applying state for domains %s, error: %s", domains, err)
}
return nil
}
Expand Down
6 changes: 3 additions & 3 deletions client/internal/dns/host_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (r *registryConfigurator) addDNSMatchPolicy(domains []string, ip string) er
return fmt.Errorf("unable to set registry value for %s, error: %s", dnsPolicyConfigConfigOptionsKey, err)
}

log.Infof("added %d match Domains to the state. Domain list: %s", len(domains), domains)
log.Infof("added %d match domains to the state. Domain list: %s", len(domains), domains)

return nil
}
Expand All @@ -152,10 +152,10 @@ func (r *registryConfigurator) restoreHostDNS() error {
func (r *registryConfigurator) updateSearchDomains(domains []string) error {
err := r.setInterfaceRegistryKeyStringValue(interfaceConfigSearchListKey, strings.Join(domains, ","))
if err != nil {
return fmt.Errorf("adding search Domain failed with error: %s", err)
return fmt.Errorf("adding search domain failed with error: %s", err)
}

log.Infof("updated the search Domains in the registry with %d Domains. Domain list: %s", len(domains), domains)
log.Infof("updated the search domains in the registry with %d domains. Domain list: %s", len(domains), domains)

return nil
}
Expand Down
2 changes: 1 addition & 1 deletion client/internal/dns/local_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func TestLocalResolver_ServeDNS(t *testing.T) {

answerString := responseMSG.Answer[0].String()
if !strings.Contains(answerString, testCase.inputRecord.Name) {
t.Fatalf("answer doesn't contain the same Domain name: \nWant: %s\nGot:%s", testCase.name, answerString)
t.Fatalf("answer doesn't contain the same domain name: \nWant: %s\nGot:%s", testCase.name, answerString)
}
if !strings.Contains(answerString, dns.Type(testCase.inputRecord.Type).String()) {
t.Fatalf("answer doesn't contain the correct type: \nWant: %s\nGot:%s", dns.Type(testCase.inputRecord.Type).String(), answerString)
Expand Down
2 changes: 1 addition & 1 deletion client/internal/dns/network_manager_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ func (n *networkManagerDbusConfigurator) applyDNSConfig(config HostDNSConfig) er
connSettings[networkManagerDbusIPv4Key][networkManagerDbusDNSPriorityKey] = dbus.MakeVariant(priority)
connSettings[networkManagerDbusIPv4Key][networkManagerDbusDNSSearchKey] = dbus.MakeVariant(newDomainList)

log.Infof("adding %d search Domains and %d match Domains. Search list: %s , Match list: %s", len(searchDomains), len(matchDomains), searchDomains, matchDomains)
log.Infof("adding %d search domains and %d match domains. Search list: %s , Match list: %s", len(searchDomains), len(matchDomains), searchDomains, matchDomains)
err = n.reApplyConnectionSettings(connSettings, configVersion)
if err != nil {
return fmt.Errorf("got an error while reapplying the connection with new settings, error: %s", err)
Expand Down
4 changes: 2 additions & 2 deletions client/internal/dns/resolvconf_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ func (r *resolvconf) applyDNSConfig(config HostDNSConfig) error {
if err != nil {
log.Error(err)
}
return fmt.Errorf("unable to configure DNS for this peer using resolvconf manager without a nameserver group with all Domains configured")
return fmt.Errorf("unable to configure DNS for this peer using resolvconf manager without a nameserver group with all domains configured")
}

searchDomainList := searchDomains(config)
Expand All @@ -62,7 +62,7 @@ func (r *resolvconf) applyDNSConfig(config HostDNSConfig) error {
return err
}

log.Infof("added %d search Domains. Search list: %s", len(searchDomainList), searchDomainList)
log.Infof("added %d search domains. Search list: %s", len(searchDomainList), searchDomainList)
return nil
}

Expand Down
6 changes: 3 additions & 3 deletions client/internal/dns/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ func (s *DefaultServer) buildUpstreamHandlerUpdate(nameServerGroups []*nbdns.Nam
continue
}

// when upstream fails to resolve Domain several times over all it servers
// when upstream fails to resolve domain several times over all it servers
// it will calls this hook to exclude self from the configuration and
// reapply DNS settings, but it not touch the original configuration and serial number
// because it is temporal deactivation until next try
Expand All @@ -364,13 +364,13 @@ func (s *DefaultServer) buildUpstreamHandlerUpdate(nameServerGroups []*nbdns.Nam

if len(nsGroup.Domains) == 0 {
handler.stop()
return nil, fmt.Errorf("received a non primary nameserver group with an empty Domain list")
return nil, fmt.Errorf("received a non primary nameserver group with an empty domain list")
}

for _, domain := range nsGroup.Domains {
if domain == "" {
handler.stop()
return nil, fmt.Errorf("received a nameserver group with an empty Domain element")
return nil, fmt.Errorf("received a nameserver group with an empty domain element")
}
muxUpdates = append(muxUpdates, muxUpdate{
domain: domain,
Expand Down
4 changes: 2 additions & 2 deletions client/internal/dns/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ func TestDNSServerUpstreamDeactivateCallback(t *testing.T) {
}
got := strings.Join(domains, ",")
if expected != got {
t.Errorf("expected Domains list: %q, got %q", expected, got)
t.Errorf("expected domains list: %q, got %q", expected, got)
}

reactivate()
Expand All @@ -581,7 +581,7 @@ func TestDNSServerUpstreamDeactivateCallback(t *testing.T) {
}
got = strings.Join(domains, ",")
if expected != got {
t.Errorf("expected Domains list: %q, got %q", expected, domainsUpdate)
t.Errorf("expected domains list: %q, got %q", expected, domainsUpdate)
}
}

Expand Down
2 changes: 1 addition & 1 deletion client/internal/dns/service_listener.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (s *serviceViaListener) evalListenAddress() (string, int, error) {
}

// shouldApplyPortFwd decides whether to apply eBPF program to capture DNS traffic on port 53.
// This is needed because on some operating systems if we start a DNS server not on a default port 53, the Domain name
// This is needed because on some operating systems if we start a DNS server not on a default port 53, the domain name
// resolution won't work.
// So, in case we are running on Linux and picked a non-default port (53) we should fall back to the eBPF solution that will capture
// traffic on port 53 and forward it to a local DNS server running on 5053.
Expand Down
4 changes: 2 additions & 2 deletions client/internal/dns/systemd_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ func (s *systemdDbusConfigurator) applyDNSConfig(config HostDNSConfig) error {
log.Infof("removing %s:%d as main DNS forwarder for this peer", config.ServerIP, config.ServerPort)
}

log.Infof("adding %d search Domains and %d match Domains. Search list: %s , Match list: %s", len(searchDomains), len(matchDomains), searchDomains, matchDomains)
log.Infof("adding %d search domains and %d match domains. Search list: %s , Match list: %s", len(searchDomains), len(matchDomains), searchDomains, matchDomains)
err = s.setDomainsForInterface(domainsInput)
if err != nil {
log.Error(err)
Expand All @@ -143,7 +143,7 @@ func (s *systemdDbusConfigurator) applyDNSConfig(config HostDNSConfig) error {
func (s *systemdDbusConfigurator) setDomainsForInterface(domainsInput []systemdDbusLinkDomainsInput) error {
err := s.callLinkMethod(systemdDbusSetDomainsMethodSuffix, domainsInput)
if err != nil {
return fmt.Errorf("setting Domains configuration failed with error: %s", err)
return fmt.Errorf("setting domains configuration failed with error: %s", err)
}
return s.flushCaches()
}
Expand Down

0 comments on commit 077d0b9

Please sign in to comment.