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