chore: support IN-PORT rule

This commit is contained in:
wwqgtxx
2022-11-11 23:36:06 +08:00
parent 64be213b66
commit b2d7149a95
13 changed files with 60 additions and 14 deletions

View File

@ -22,6 +22,14 @@ func NewSocket(target socks5.Addr, conn net.Conn, source C.Type) *context.ConnCo
metadata.SrcPort = port
}
}
localAddr := conn.LocalAddr()
// Filter when net.Addr interface is nil
if localAddr != nil {
if ip, port, err := parseAddr(localAddr.String()); err == nil {
metadata.InIP = ip
metadata.InPort = port
}
}
return context.NewConnContext(conn, metadata)
}