🐞 Remove incorrect -delegates warning

fixes, when server is started with `-delegates` unset:

```
-delegates: arguments should be in the format "delegatedDomain=nameserver", not ""
```
This commit is contained in:
Brian Cunnie
2024-06-22 14:55:27 -07:00
parent 74a5c2edfd
commit ba85d1aacf
2 changed files with 4 additions and 1 deletions

View File

@@ -173,7 +173,7 @@ var _ = Describe("flags", func() {
flags = []string{"-delegates="}
})
It("should give an informative message", func() {
Expect(string(serverSession.Err.Contents())).Should(MatchRegexp(`-delegates: arguments should be in the format "delegatedDomain=nameserver", not ""`))
Expect(string(serverSession.Err.Contents())).Should(Not(MatchRegexp(`-delegates`)))
})
})
When("the arguments are mangled", func() {

View File

@@ -250,6 +250,9 @@ func NewXip(blocklistURL string, nameservers []string, addresses []string, deleg
}
// Parse and set the nameservers of our delegated domains
for _, delegate := range delegates {
if delegate == "" { // most common case: no delegates defined
continue
}
delegatedDomainAndNameserver := strings.Split(strings.ToLower(delegate), "=")
if len(delegatedDomainAndNameserver) != 2 {
logmessages = append(logmessages, fmt.Sprintf(`-delegates: arguments should be in the format "delegatedDomain=nameserver", not "%s"`, delegate))