fix: npe panic
This commit is contained in:
parent
40ee33f062
commit
5cd593f31c
1 changed files with 7 additions and 3 deletions
|
@ -13,10 +13,14 @@ func NewSocket(target socks5.Addr, conn net.Conn, source C.Type) *context.ConnCo
|
|||
metadata := parseSocksAddr(target)
|
||||
metadata.NetWork = C.TCP
|
||||
metadata.Type = source
|
||||
if ip, port, err := parseAddr(conn.RemoteAddr().String()); err == nil {
|
||||
remoteAddr := conn.RemoteAddr()
|
||||
// Filter when net.Addr interface is nil
|
||||
if remoteAddr != nil {
|
||||
if ip, port, err := parseAddr(remoteAddr.String()); err == nil {
|
||||
metadata.SrcIP = ip
|
||||
metadata.SrcPort = port
|
||||
}
|
||||
}
|
||||
|
||||
return context.NewConnContext(conn, metadata)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue