Fixing issue #5376 by adding a check to parse out Zone info (#5387)

* Fixing #5376 by adding a check to parse out Zone information

Signed-off-by: Tintin <samrath.sodi@gmail.com>

* using IndexByte instead of strings.Split()

Signed-off-by: Tintin <samrath.sodi@gmail.com>

* using plugin logger for logging parsing failure

Signed-off-by: Tintin <samrath.sodi@gmail.com>

* using var keywork instead of short declaration operator

Signed-off-by: Tintin <samrath.sodi@gmail.com>

* reordering imports

Signed-off-by: Tintin <samrath.sodi@gmail.com>
This commit is contained in:
Tintin
2022-05-20 10:22:30 +05:30
committed by GitHub
parent d594d61341
commit 71f68a3363
3 changed files with 41 additions and 3 deletions

View File

@@ -12,6 +12,7 @@ import (
type ResponseWriter struct {
TCP bool // if TCP is true we return an TCP connection instead of an UDP one.
RemoteIP string
Zone string
}
// LocalAddr returns the local address, 127.0.0.1:53 (UDP, TCP if t.TCP is true).
@@ -33,9 +34,9 @@ func (t *ResponseWriter) RemoteAddr() net.Addr {
ip := net.ParseIP(remoteIP)
port := 40212
if t.TCP {
return &net.TCPAddr{IP: ip, Port: port, Zone: ""}
return &net.TCPAddr{IP: ip, Port: port, Zone: t.Zone}
}
return &net.UDPAddr{IP: ip, Port: port, Zone: ""}
return &net.UDPAddr{IP: ip, Port: port, Zone: t.Zone}
}
// WriteMsg implements dns.ResponseWriter interface.