mirror of
https://github.com/SunBK201/UA3F.git
synced 2025-12-16 16:57:08 +00:00
feat: update ForwardTCP method signature and usage in SOCKS5 server
This commit is contained in:
parent
0424611bc7
commit
f5572ac638
@ -13,6 +13,7 @@ import (
|
|||||||
type Server interface {
|
type Server interface {
|
||||||
Start() error
|
Start() error
|
||||||
HandleClient(net.Conn)
|
HandleClient(net.Conn)
|
||||||
|
ForwardTCP(client, target net.Conn, destAddr string)
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewServer(cfg *config.Config, rw *rewrite.Rewriter) (Server, error) {
|
func NewServer(cfg *config.Config, rw *rewrite.Rewriter) (Server, error) {
|
||||||
|
|||||||
@ -97,7 +97,7 @@ func (s *Server) HandleClient(client net.Conn) {
|
|||||||
_ = client.Close()
|
_ = client.Close()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
s.forwardTCP(client, target, destAddrPort)
|
s.ForwardTCP(client, target, destAddrPort)
|
||||||
}
|
}
|
||||||
|
|
||||||
// socks5Auth performs a minimal "no-auth" negotiation.
|
// socks5Auth performs a minimal "no-auth" negotiation.
|
||||||
@ -206,15 +206,15 @@ func (s *Server) socks5Connect(client net.Conn, destAddrPort string) (net.Conn,
|
|||||||
return target, nil
|
return target, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// forwardTCP proxies traffic in both directions.
|
// ForwardTCP proxies traffic in both directions.
|
||||||
// target->client uses raw copy.
|
// target->client uses raw copy.
|
||||||
// client->target is processed by the rewriter (or raw if cached).
|
// client->target is processed by the rewriter (or raw if cached).
|
||||||
func (s *Server) forwardTCP(client, target net.Conn, destAddrPort string) {
|
func (s *Server) ForwardTCP(client, target net.Conn, destAddr string) {
|
||||||
// Server -> Client (raw)
|
// Server -> Client (raw)
|
||||||
go utils.CopyHalf(client, target)
|
go utils.CopyHalf(client, target)
|
||||||
|
|
||||||
// Client -> Server (rewriter)
|
// Client -> Server (rewriter)
|
||||||
go utils.ProxyHalf(target, client, s.rw, destAddrPort)
|
go utils.ProxyHalf(target, client, s.rw, destAddr)
|
||||||
}
|
}
|
||||||
|
|
||||||
// handleUDPAssociate handles a UDP ASSOCIATE request by creating a UDP relay socket.
|
// handleUDPAssociate handles a UDP ASSOCIATE request by creating a UDP relay socket.
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user