mirror of
https://github.com/daeuniverse/dae.git
synced 2025-02-06 09:08:34 +07:00
fix: should disable rush-answer detecting when dns packet sent to loopback
This commit is contained in:
parent
96967d59c8
commit
ea568ebce5
@ -234,7 +234,7 @@ func (c *DnsController) UpdateDnsCache(host string, typ dnsmessage.Type, answers
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *DnsController) DnsRespHandlerFactory(req *udpRequest, validateRushAnsFunc func(from netip.AddrPort) bool) func(data []byte, from netip.AddrPort) (msg *dnsmessage.Message, err error) {
|
func (c *DnsController) DnsRespHandlerFactory(validateRushAnsFunc func(from netip.AddrPort) bool) func(data []byte, from netip.AddrPort) (msg *dnsmessage.Message, err error) {
|
||||||
return func(data []byte, from netip.AddrPort) (msg *dnsmessage.Message, err error) {
|
return func(data []byte, from netip.AddrPort) (msg *dnsmessage.Message, err error) {
|
||||||
// Do not return conn-unrelated err in this func.
|
// Do not return conn-unrelated err in this func.
|
||||||
|
|
||||||
@ -362,11 +362,14 @@ func (c *DnsController) dialSend(req *udpRequest, data []byte, upstream *dns.Ups
|
|||||||
}
|
}
|
||||||
|
|
||||||
// dnsRespHandler caches dns response and check rush answers.
|
// dnsRespHandler caches dns response and check rush answers.
|
||||||
dnsRespHandler := c.DnsRespHandlerFactory(req, func(from netip.AddrPort) bool {
|
dnsRespHandler := c.DnsRespHandlerFactory(func(from netip.AddrPort) bool {
|
||||||
// We only validate rush-ans when outbound is direct and pkt does not send to a home device.
|
// We only validate rush-ans when outbound is direct and pkt does not send to a home device.
|
||||||
// Because additional record OPT may not be supported by home router.
|
// Because additional record OPT may not be supported by home router.
|
||||||
// So se should trust home devices even if they make rush-answer (or looks like).
|
// So se should trust home devices even if they make rush-answer (or looks like).
|
||||||
return dialArgument.bestDialer.Property().Name == "direct" && !from.Addr().IsPrivate()
|
return dialArgument.bestDialer.Property().Name == "direct" &&
|
||||||
|
!from.Addr().IsPrivate() &&
|
||||||
|
!from.Addr().IsLoopback() &&
|
||||||
|
!from.Addr().IsUnspecified()
|
||||||
})
|
})
|
||||||
// Dial and send.
|
// Dial and send.
|
||||||
var respMsg *dnsmessage.Message
|
var respMsg *dnsmessage.Message
|
||||||
|
Loading…
Reference in New Issue
Block a user