From 1a8ac148ca8ff25b72b388e563b37fbbdfa4bffc Mon Sep 17 00:00:00 2001 From: fatedier Date: Thu, 18 Oct 2018 13:55:51 +0800 Subject: [PATCH] fix xtcp visitor panic --- client/proxy_manager.go | 12 ++++++------ client/visitor.go | 9 +++++++++ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/client/proxy_manager.go b/client/proxy_manager.go index bd193bb..fe175a0 100644 --- a/client/proxy_manager.go +++ b/client/proxy_manager.go @@ -13,12 +13,12 @@ import ( ) const ( - ProxyStatusNew = "new" - ProxyStatusStartErr = "start error" - ProxyStatusWaitStart = "wait start" - ProxyStatusRunning = "running" - ProxyStatusCheckFailed = "check failed" - ProxyStatusClosed = "closed" + ProxyStatusNew = "new" + ProxyStatusStartErr = "start error" + ProxyStatusWaitStart = "wait start" + ProxyStatusRunning = "running" + ProxyStatusCheckFailed = "check failed" + ProxyStatusClosed = "closed" ) type ProxyManager struct { diff --git a/client/visitor.go b/client/visitor.go index 6e1e1c8..6634401 100644 --- a/client/visitor.go +++ b/client/visitor.go @@ -202,7 +202,16 @@ func (sv *XtcpVisitor) handleConn(userConn frpNet.Conn) { raddr, err := net.ResolveUDPAddr("udp", fmt.Sprintf("%s:%d", g.GlbClientCfg.ServerAddr, g.GlbClientCfg.ServerUdpPort)) + if err != nil { + sv.Error("resolve server UDP addr error") + return + } + visitorConn, err := net.DialUDP("udp", nil, raddr) + if err != nil { + sv.Warn("dial server udp addr error: %v", err) + return + } defer visitorConn.Close() now := time.Now().Unix()