From fd1b4dc4899e19ad0651e09424dba1bb7dccaed0 Mon Sep 17 00:00:00 2001 From: lovedboy Date: Tue, 24 May 2016 13:18:04 +0800 Subject: [PATCH] listenedAddr fix when TCP or UDP bind dynamic port --- client.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/client.go b/client.go index dbebd1ba..3759bfd1 100644 --- a/client.go +++ b/client.go @@ -222,18 +222,20 @@ func listen(tcp, utp bool, networkSuffix, addr string) (tcpL net.Listener, utpSo if tcp && utp && port == 0 { return listenBothSameDynamicPort(networkSuffix, host) } - listenedAddr = addr if tcp { tcpL, err = listenTCP(networkSuffix, addr) if err != nil { return } + listenedAddr = tcpL.Addr().String() + } if utp { utpSock, err = listenUTP(networkSuffix, addr) if err != nil && tcp { tcpL.Close() } + listenedAddr = utpSock.Addr().String() } return } -- 2.48.1