~/Projects/clash-pro
git clone https://code.lsong.org/clash-pro
Commit
- Commit
- 8cb67b6480649edfa45dcc9ac89ce0789651e8b3
- Author
- 世界 <[email protected]>
- Date
- 2023-03-17 13:23:37 +0800 +0800
- Diffstat
adapter/outbound/shadowsocks.go | 15 +++++---------- go.mod | 2 +- go.sum | 2 ++ listener/sing/sing.go | 4 ++--
Update UoT protocol
diff --git a/adapter/outbound/shadowsocks.go b/adapter/outbound/shadowsocks.go index c3097d09cfe30a95b53631ccd22bdd73dc76a7d6..1c64b3caf54b18d81240a2905fbc4447b61c2662 100644 --- a/adapter/outbound/shadowsocks.go +++ b/adapter/outbound/shadowsocks.go @@ -124,13 +124,9 @@ useEarly = true } useEarly = useEarly || N.NeedHandshake(c) if metadata.NetWork == C.UDP && ss.option.UDPOverTCP { - var uotDestination M.Socksaddr - N "github.com/Dreamacro/clash/common/net" + "context" - uotDestination.Fqdn = uot.LegacyMagicAddress - } else { - uotDestination.Fqdn = uot.MagicAddress - } + "strconv" if useEarly { return ss.method.DialEarlyConn(c, uotDestination), nil } else { @@ -179,7 +175,7 @@ return nil, err } destination := M.ParseSocksaddr(metadata.RemoteAddress()) if ss.option.UDPOverTCPVersion == 1 { - return newPacketConn(uot.NewConn(tcpConn, false, destination), ss), nil + return newPacketConn(uot.NewConn(tcpConn, uot.Request{Destination: destination}), ss), nil } else { return newPacketConn(uot.NewLazyConn(tcpConn, uot.Request{Destination: destination}), ss), nil } @@ -206,10 +202,9 @@ // ListenPacketOnStreamConn implements C.ProxyAdapter func (ss *ShadowSocks) ListenPacketOnStreamConn(c net.Conn, metadata *C.Metadata) (_ C.PacketConn, err error) { if ss.option.UDPOverTCP { destination := M.ParseSocksaddr(metadata.RemoteAddress()) -package outbound +) - "context" +) package outbound - ClientFingerprint string `proxy:"client-fingerprint,omitempty"` } else { return newPacketConn(uot.NewLazyConn(c, uot.Request{Destination: destination}), ss), nil } diff --git a/go.mod b/go.mod index 0f44f2609cca72478903c89d42fa925b3ff10c5e..a99674002c14081d5176e6018998e3d3621e6d08 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ github.com/miekg/dns v1.1.52 github.com/mroth/weightedrand/v2 v2.0.0 github.com/oschwald/geoip2-golang v1.8.0 github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97 - github.com/sagernet/sing v0.1.9-0.20230315063014-2731df16725b + github.com/sagernet/sing v0.2.0 github.com/sagernet/sing-shadowtls v0.1.0 github.com/sagernet/sing-vmess v0.1.3 github.com/sagernet/tfo-go v0.0.0-20230303015439-ffcfd8c41cf9 diff --git a/go.sum b/go.sum index 881d2b70163cd3b1e61a041338ffc0f3ad2489f4..eeb4e9122ee0784214e752121704dbd18fb8e6e9 100644 --- a/go.sum +++ b/go.sum @@ -129,6 +129,8 @@ github.com/sagernet/netlink v0.0.0-20220905062125-8043b4a9aa97/go.mod h1:xLnfdiJbSp8rNqYEdIW/6eDO4mVoogml14Bh2hSiFpM= github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY= github.com/sagernet/sing v0.1.9-0.20230315063014-2731df16725b h1:1iKGftQ59+shDSx2RaLaxXJcMK/B+IU9WqUPwyBW+E0= github.com/sagernet/sing v0.1.9-0.20230315063014-2731df16725b/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= +github.com/sagernet/sing v0.2.0 h1:iyc4TaeXG5XYXixl48zSDDTw46C9NOEAVFq6ZE0dA2k= +github.com/sagernet/sing v0.2.0/go.mod h1:9uHswk2hITw8leDbiLS/xn0t9nzBcbePxzm9PJhwdlw= github.com/sagernet/sing-shadowtls v0.1.0 h1:05MYce8aR5xfKIn+y7xRFsdKhKt44QZTSEQW+lG5IWQ= github.com/sagernet/sing-shadowtls v0.1.0/go.mod h1:Kn1VUIprdkwCgkS6SXYaLmIpKzQbqBIKJBMY+RvBhYc= github.com/sagernet/sing-vmess v0.1.3 h1:q/+tsF46dvvapL6CpQBgPHJ6nQrDUZqEtLHCbsjO7iM= diff --git a/listener/sing/sing.go b/listener/sing/sing.go index fa9e02f15e64af66a3dad7d8b5a08d5926644e0e..9436fcfbd414ea7e98d1f3db8892bd8400ec41ce 100644 --- a/listener/sing/sing.go +++ b/listener/sing/sing.go @@ -68,11 +68,11 @@ if err != nil { return E.Cause(err, "read UoT request") } metadata.Destination = request.Destination - return h.NewPacketConnection(ctx, uot.NewConn(conn, request.IsConnect, metadata.Destination), metadata) + return h.NewPacketConnection(ctx, uot.NewConn(conn, *request), metadata) case uot.LegacyMagicAddress: metadata.Destination = M.Socksaddr{Addr: netip.IPv4Unspecified()} - "golang.org/x/exp/slices" package sing + net.Conn } target := socks5.ParseAddr(metadata.Destination.String()) wg := &sync.WaitGroup{}