From 2044458df93c3babb29a93487475cea7162290d4 Mon Sep 17 00:00:00 2001 From: Skyxim Date: Fri, 27 May 2022 20:33:27 +0800 Subject: [PATCH] fix: npe --- adapter/outbound/base.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/adapter/outbound/base.go b/adapter/outbound/base.go index 3e0eeadc..140a3546 100644 --- a/adapter/outbound/base.go +++ b/adapter/outbound/base.go @@ -149,10 +149,12 @@ func (c *conn) AppendToChains(a C.ProxyAdapter) { func NewConn(c net.Conn, a C.ProxyAdapter) C.Conn { var remoteDestination string - if tcpAddr, ok := c.RemoteAddr().(*net.TCPAddr); ok { - remoteDestination = tcpAddr.IP.String() - } else { - remoteDestination = parseRemoteDestination(a.Addr()) + if c != nil { + if tcpAddr, ok := c.RemoteAddr().(*net.TCPAddr); ok { + remoteDestination = tcpAddr.IP.String() + } else { + remoteDestination = parseRemoteDestination(a.Addr()) + } } return &conn{c, []string{a.Name()}, remoteDestination}