mirror of
https://github.com/daeuniverse/dae.git
synced 2025-07-07 00:42:22 +07:00
fix: domain match
This commit is contained in:
@ -372,7 +372,7 @@ func (c *ControlPlane) finishInitDnsUpstreamResolve(raw common.UrlOrEmpty, dnsUp
|
||||
A: dnsUpstream.Ip4.As4(),
|
||||
},
|
||||
}}
|
||||
if err = c.UpdateDnsCache(fqdn, typ, answers, deadline); err != nil {
|
||||
if err = c.UpdateDnsCache(dnsUpstream.Hostname, typ, answers, deadline); err != nil {
|
||||
c = nil
|
||||
return
|
||||
}
|
||||
@ -391,7 +391,7 @@ func (c *ControlPlane) finishInitDnsUpstreamResolve(raw common.UrlOrEmpty, dnsUp
|
||||
AAAA: dnsUpstream.Ip6.As16(),
|
||||
},
|
||||
}}
|
||||
if err = c.UpdateDnsCache(fqdn, typ, answers, deadline); err != nil {
|
||||
if err = c.UpdateDnsCache(dnsUpstream.Hostname, typ, answers, deadline); err != nil {
|
||||
c = nil
|
||||
return
|
||||
}
|
||||
|
@ -331,12 +331,19 @@ loop:
|
||||
}
|
||||
|
||||
func (c *ControlPlane) UpdateDnsCache(host string, typ dnsmessage.Type, answers []dnsmessage.Resource, deadline time.Time) (err error) {
|
||||
c.dnsCacheMu.Lock()
|
||||
fqdn := strings.ToLower(host)
|
||||
if !strings.HasSuffix(fqdn, ".") {
|
||||
fqdn += "."
|
||||
var fqdn string
|
||||
if strings.HasSuffix(host, ".") {
|
||||
fqdn = host
|
||||
host = host[:len(host)-1]
|
||||
} else {
|
||||
fqdn = host + "."
|
||||
}
|
||||
// Bypass pure IP.
|
||||
if _, err = netip.ParseAddr(host); err == nil {
|
||||
return nil
|
||||
}
|
||||
cacheKey := fqdn + typ.String()
|
||||
c.dnsCacheMu.Lock()
|
||||
cache, ok := c.dnsCache[cacheKey]
|
||||
if ok {
|
||||
c.dnsCacheMu.Unlock()
|
||||
|
Reference in New Issue
Block a user