Skip to content

Commit

Permalink
Allow stubzones to have multiple DNS servers since forwarder logic al…
Browse files Browse the repository at this point in the history
…lows this. Ex: domain/1.1.1.1:543,2.2.2.2:53
  • Loading branch information
gondor committed Jun 5, 2016
1 parent f28077c commit 365de87
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,28 +255,29 @@ func main() {
log.Fatalf("The --stubzones argument is invalid")
}

hostPort = segments[1]
hostPort = strings.TrimSpace(hostPort)
if strings.HasSuffix(hostPort, "]") {
hostPort += ":53"
} else if !strings.Contains(hostPort, ":") {
hostPort += ":53"
}
hosts := strings.Split(segments[1], ",")
for _, hostPort := range hosts {
hostPort = strings.TrimSpace(hostPort)
if strings.HasSuffix(hostPort, "]") {
hostPort += ":53"
} else if !strings.Contains(hostPort, ":") {
hostPort += ":53"
}

if err := validateHostPort(hostPort); err != nil {
log.Fatalf("This stubzones server address invalid: %s", err)
}
if err := validateHostPort(hostPort); err != nil {
log.Fatalf("This stubzones server address invalid: %s", err)
}

for _, sdomain := range strings.Split(segments[0], ",") {
if dns.CountLabel(sdomain) < 1 {
log.Fatalf("This stubzones domain is not a FQDN: %s", sdomain)
for _, sdomain := range strings.Split(segments[0], ",") {
if dns.CountLabel(sdomain) < 1 {
log.Fatalf("This stubzones domain is not a FQDN: %s", sdomain)
}
sdomain = strings.TrimSpace(sdomain)
sdomain = dns.Fqdn(sdomain)
stubmap[sdomain] = append(stubmap[sdomain], hostPort)
}
sdomain = strings.TrimSpace(sdomain)
sdomain = dns.Fqdn(sdomain)
stubmap[sdomain] = append(stubmap[sdomain], hostPort)
}
}

config.Stub = &stubmap
}

Expand Down

0 comments on commit 365de87

Please sign in to comment.