Pass docker bridge ip to dns server, and filter it out of upstream dns ips.
This commit is contained in:
1 parent
6d0db90f43
commit
58ae0cd113
4 files changed
+26
-9
No files matched your search
+14
-1
@@ -38,8 +38,18 @@ type DNSServer struct {
|
||||
udpClient *dns.Client
|
||||
}
|
||||
|
||||
func NewDNSServer(ns *Nameserver, domain string, address string, ttl uint32, clientTimeout time.Duration) (*DNSServer, error) {
|
||||
func filter(ss []string, s string) []string {
|
||||
for i := 0; i < len(ss); {
|
||||
if ss[i] == s {
|
||||
ss = append(ss[:i], ss[i+1:]...)
|
||||
continue
|
||||
}
|
||||
i++
|
||||
}
|
||||
return ss
|
||||
}
|
||||
|
||||
func NewDNSServer(ns *Nameserver, domain, address, effectiveAddress string, ttl uint32, clientTimeout time.Duration) (*DNSServer, error) {
|
||||
s := &DNSServer{
|
||||
ns: ns,
|
||||
domain: dns.Fqdn(domain),
|
||||
@@ -52,6 +62,9 @@ func NewDNSServer(ns *Nameserver, domain string, address string, ttl uint32, cli
|
||||
if s.upstream, err = dns.ClientConfigFromFile(etcResolvConf); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if s.upstream != nil {
|
||||
s.upstream.Servers = filter(s.upstream.Servers, effectiveAddress)
|
||||
}
|
||||
|
||||
err = s.listen(address)
|
||||
return s, err
|
||||
|
||||
Reference in new issue
Block a user