diff --git a/service/cziti/dns-proxy.go b/service/cziti/dns-proxy.go index a8addc3d..03a3f557 100644 --- a/service/cziti/dns-proxy.go +++ b/service/cziti/dns-proxy.go @@ -58,14 +58,12 @@ func processDNSquery(packet []byte, p *net.UDPAddr, s *net.UDPConn) { if ip == nil { // no direct hit. need to now check to see if the dns query used a connection-specific local domain for _, d := range domains { - if strings.HasSuffix(dnsName, d) { - dnsNameTrimmed := strings.Trim(dnsName, d) + domain := d + if strings.HasSuffix(dnsName, domain) { + dnsNameTrimmed := strings.TrimRight(dnsName, domain) // dns request has domain appended - removing and resolving ip = DNS.Resolve(dnsNameTrimmed) - if ip != nil { - log.Debugf("DNS %s failed at first but succeeded by looking up %s", dnsName, dnsNameTrimmed) - break - } + break } } } @@ -282,7 +280,7 @@ func runDNSproxy(dnsServers []string) { log.Tracef("proxy resolved %v from %v", reply.Question[0].Name, req.s.RemoteAddr()) req.s.WriteMsgUDP(rep, nil, req.peer) } else { - log.Tracef("matching request was not found for ", + log.Tracef("matching request was not found for %s %s", dns.Type(reply.Question[0].Qtype), reply.Question[0].Name) } } diff --git a/service/cziti/windns.go b/service/cziti/windns.go index 9464944f..6c15284c 100644 --- a/service/cziti/windns.go +++ b/service/cziti/windns.go @@ -44,13 +44,14 @@ func ResetDNS() { } func GetConnectionSpecificDomains() []string { - script := `Get-DnsClient | Select-Object ConnectionSpecificSuffix | Get-Unique | ForEach-Object { $_.ConnectionSpecificSuffix }` + script := `Get-DnsClient | Select-Object ConnectionSpecificSuffix -Unique | ForEach-Object { $_.ConnectionSpecificSuffix }` cmd := exec.Command("powershell", "-Command", script) cmd.Stderr = os.Stdout output := new(bytes.Buffer) cmd.Stdout = output + log.Tracef("running powershell command to get ConnectionSpecificSuffixes: %s", script) err := cmd.Run() if err != nil { @@ -64,8 +65,10 @@ func GetConnectionSpecificDomains() []string { break } domain = strings.TrimSpace(domain) - if !strings.HasSuffix(domain, ".") { - names = append(names, domain + ".") + if "" != domain { + if !strings.HasSuffix(domain, ".") { + names = append(names, domain+".") + } } } return names