From 6ba3a17d7bad620a107d14efd88996caf7274856 Mon Sep 17 00:00:00 2001 From: gVisor bot Date: Tue, 27 Jul 2021 13:58:29 +0800 Subject: [PATCH] Chore: split SOCKS version inbound metadata type (#1513) --- constant/metadata.go | 7 +++++-- listener/socks/tcp.go | 4 ++-- listener/socks/udp.go | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/constant/metadata.go b/constant/metadata.go index 93ef406d..9fff773b 100644 --- a/constant/metadata.go +++ b/constant/metadata.go @@ -17,7 +17,8 @@ const ( HTTP Type = iota HTTPCONNECT - SOCKS + SOCKS4 + SOCKS5 REDIR TPROXY ) @@ -43,7 +44,9 @@ func (t Type) String() string { return "HTTP" case HTTPCONNECT: return "HTTP Connect" - case SOCKS: + case SOCKS4: + return "Socks4" + case SOCKS5: return "Socks5" case REDIR: return "Redir" diff --git a/listener/socks/tcp.go b/listener/socks/tcp.go index 587af221..20e48f85 100644 --- a/listener/socks/tcp.go +++ b/listener/socks/tcp.go @@ -79,7 +79,7 @@ func HandleSocks4(conn net.Conn, in chan<- C.ConnContext) { if c, ok := conn.(*net.TCPConn); ok { c.SetKeepAlive(true) } - in <- inbound.NewSocket(socks5.ParseAddr(addr), conn, C.SOCKS) + in <- inbound.NewSocket(socks5.ParseAddr(addr), conn, C.SOCKS4) } func HandleSocks5(conn net.Conn, in chan<- C.ConnContext) { @@ -96,5 +96,5 @@ func HandleSocks5(conn net.Conn, in chan<- C.ConnContext) { io.Copy(ioutil.Discard, conn) return } - in <- inbound.NewSocket(target, conn, C.SOCKS) + in <- inbound.NewSocket(target, conn, C.SOCKS5) } diff --git a/listener/socks/udp.go b/listener/socks/udp.go index ca75b2c8..f822d76a 100644 --- a/listener/socks/udp.go +++ b/listener/socks/udp.go @@ -70,7 +70,7 @@ func handleSocksUDP(pc net.PacketConn, in chan<- *inbound.PacketAdapter, buf []b bufRef: buf, } select { - case in <- inbound.NewPacket(target, packet, C.SOCKS): + case in <- inbound.NewPacket(target, packet, C.SOCKS5): default: } }