diff options
| author | Shulhan <ms@kilabit.info> | 2018-09-26 23:20:02 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2018-09-26 23:20:02 +0700 |
| commit | 0e821e8b243c7ae067f8fccfb172c233238fe0fd (patch) | |
| tree | a4e69021be36dcf61a1f49966adac729935419d2 | |
| parent | 2b642292b3c2d4ae46308f01428bc955e974ad98 (diff) | |
| download | pakakeh.go-0e821e8b243c7ae067f8fccfb172c233238fe0fd.tar.xz | |
lib/dns: use client address if send or query address parameter is nil
| -rw-r--r-- | lib/dns/udpclient.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/dns/udpclient.go b/lib/dns/udpclient.go index dde5b708..d883e152 100644 --- a/lib/dns/udpclient.go +++ b/lib/dns/udpclient.go @@ -100,6 +100,10 @@ func (cl *UDPClient) Lookup(qtype uint16, qclass uint16, qname []byte) ( // Query send DNS query to name server "ns" and return the unpacked response. // func (cl *UDPClient) Query(msg *Message, ns net.Addr) (*Message, error) { + if ns == nil { + ns = cl.Addr + } + _, err := cl.Send(msg, ns) if err != nil { return nil, err @@ -151,7 +155,7 @@ func (cl *UDPClient) Recv(msg *Message) (n int, err error) { // func (cl *UDPClient) Send(msg *Message, ns net.Addr) (n int, err error) { if ns == nil { - return + ns = cl.Addr } raddr := ns.(*net.UDPAddr) |
