all: fix resource leaks with missing .Close() calls

Fixes #5706

Signed-off-by: Emmanuel T Odeke <emmanuel@orijtech.com>
This commit is contained in:
Emmanuel T Odeke
2022-09-20 21:27:47 -07:00
committed by Brad Fitzpatrick
parent 9bdf0cd8cd
commit f981b1d9da
5 changed files with 21 additions and 3 deletions

View File

@@ -987,16 +987,19 @@ func (ns *Impl) acceptUDP(r *udp.ForwarderRequest) {
}
dstAddr, ok := ipPortOfNetstackAddr(sess.LocalAddress, sess.LocalPort)
if !ok {
ep.Close()
return
}
srcAddr, ok := ipPortOfNetstackAddr(sess.RemoteAddress, sess.RemotePort)
if !ok {
ep.Close()
return
}
// Handle magicDNS traffic (via UDP) here.
if dst := dstAddr.Addr(); dst == magicDNSIP || dst == magicDNSIPv6 {
if dstAddr.Port() != 53 {
ep.Close()
return // Only MagicDNS traffic runs on the service IPs for now.
}