From b83c6c9d20eff2c1556eb0d7974cd9c690a81d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Wed, 30 Aug 2023 17:53:37 +0800 Subject: [PATCH] Fix return nil addr in conn --- go.mod | 6 +++--- go.sum | 8 ++++---- inbound/naive.go | 2 +- test/go.mod | 4 ++-- test/go.sum | 2 ++ transport/hysteria/protocol.go | 4 ++-- transport/v2raygrpc/conn.go | 5 +++-- transport/v2raygrpclite/conn.go | 3 ++- transport/v2rayhttp/conn.go | 5 +++-- 9 files changed, 22 insertions(+), 17 deletions(-) diff --git a/go.mod b/go.mod index f066690e..2e81f1ce 100644 --- a/go.mod +++ b/go.mod @@ -25,9 +25,9 @@ require ( github.com/sagernet/gvisor v0.0.0-20230627031050-1ab0276e0dd2 github.com/sagernet/quic-go v0.0.0-20230825040534-0cd917b2ddda github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 - github.com/sagernet/sing v0.2.10-0.20230824115837-8d731e68853a + github.com/sagernet/sing v0.2.10-0.20230830132630-30bf19f2833c github.com/sagernet/sing-dns v0.1.9-0.20230824120133-4d5cbceb40c1 - github.com/sagernet/sing-mux v0.1.3-0.20230811111955-dc1639b5204c + github.com/sagernet/sing-mux v0.1.3-0.20230830095209-2a10ebd53ba8 github.com/sagernet/sing-shadowsocks v0.2.4 github.com/sagernet/sing-shadowsocks2 v0.1.3 github.com/sagernet/sing-shadowtls v0.1.4 @@ -50,6 +50,7 @@ require ( golang.zx2c4.com/wireguard/wgctrl v0.0.0-20230429144221-925a1e7659e6 google.golang.org/grpc v1.57.0 google.golang.org/protobuf v1.31.0 + howett.net/plist v1.0.0 ) //replace github.com/sagernet/sing => ../sing @@ -93,6 +94,5 @@ require ( google.golang.org/genproto/googleapis/rpc v0.0.0-20230525234030-28d5490b6b19 // indirect gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f // indirect gopkg.in/yaml.v3 v3.0.1 // indirect - howett.net/plist v1.0.0 // indirect lukechampine.com/blake3 v1.2.1 // indirect ) diff --git a/go.sum b/go.sum index cdb963fb..d9bc4a1a 100644 --- a/go.sum +++ b/go.sum @@ -114,12 +114,12 @@ github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 h1:5Th31OC6yj8byL github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691/go.mod h1:B8lp4WkQ1PwNnrVMM6KyuFR20pU8jYBD+A4EhJovEXU= github.com/sagernet/sing v0.0.0-20220817130738-ce854cda8522/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY= github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuDW9qMk= -github.com/sagernet/sing v0.2.10-0.20230824115837-8d731e68853a h1:eV4HEz9NP7eAlQ/IHD6OF2VVM6ke4Vw6htuSAsvgtDk= -github.com/sagernet/sing v0.2.10-0.20230824115837-8d731e68853a/go.mod h1:9uOZwWkhT2Z2WldolLxX34s+1svAX4i4vvz5hy8u1MA= +github.com/sagernet/sing v0.2.10-0.20230830132630-30bf19f2833c h1:J2ptRncTNy+ZHfcFYSBfTmpvmgNlSEUZz6sDjh1np/Y= +github.com/sagernet/sing v0.2.10-0.20230830132630-30bf19f2833c/go.mod h1:9uOZwWkhT2Z2WldolLxX34s+1svAX4i4vvz5hy8u1MA= github.com/sagernet/sing-dns v0.1.9-0.20230824120133-4d5cbceb40c1 h1:5w+jXz8y/8UQAxO74TjftN5okYkpg5mGvVxXunlKdqI= github.com/sagernet/sing-dns v0.1.9-0.20230824120133-4d5cbceb40c1/go.mod h1:Kg98PBJEg/08jsNFtmZWmPomhskn9Ausn50ecNm4M+8= -github.com/sagernet/sing-mux v0.1.3-0.20230811111955-dc1639b5204c h1:35/FowAvt3Z62mck0TXzVc4jS5R5CWq62qcV2P1cp0I= -github.com/sagernet/sing-mux v0.1.3-0.20230811111955-dc1639b5204c/go.mod h1:TKxqIvfQQgd36jp2tzsPavGjYTVZilV+atip1cssjIY= +github.com/sagernet/sing-mux v0.1.3-0.20230830095209-2a10ebd53ba8 h1:UyUkEUEGqfIGqzOJ7OuJry4slgcT/qb0etDJ+89LTAs= +github.com/sagernet/sing-mux v0.1.3-0.20230830095209-2a10ebd53ba8/go.mod h1:TKxqIvfQQgd36jp2tzsPavGjYTVZilV+atip1cssjIY= github.com/sagernet/sing-shadowsocks v0.2.4 h1:s/CqXlvFAZhlIoHWUwPw5CoNnQ9Ibki9pckjuugtVfY= github.com/sagernet/sing-shadowsocks v0.2.4/go.mod h1:80fNKP0wnqlu85GZXV1H1vDPC/2t+dQbFggOw4XuFUM= github.com/sagernet/sing-shadowsocks2 v0.1.3 h1:WXoLvCFi5JTFBRYorf1YePGYIQyJ/zbsBM6Fwbl5kGA= diff --git a/inbound/naive.go b/inbound/naive.go index 17a206c5..63342cdf 100644 --- a/inbound/naive.go +++ b/inbound/naive.go @@ -582,7 +582,7 @@ func (c *naiveH2Conn) Close() error { } func (c *naiveH2Conn) LocalAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *naiveH2Conn) RemoteAddr() net.Addr { diff --git a/test/go.mod b/test/go.mod index 42601dde..cf854222 100644 --- a/test/go.mod +++ b/test/go.mod @@ -10,7 +10,7 @@ require ( github.com/docker/docker v24.0.5+incompatible github.com/docker/go-connections v0.4.0 github.com/gofrs/uuid/v5 v5.0.0 - github.com/sagernet/sing v0.2.10-0.20230824115837-8d731e68853a + github.com/sagernet/sing v0.2.10-0.20230830132630-30bf19f2833c github.com/sagernet/sing-shadowsocks v0.2.4 github.com/sagernet/sing-shadowsocks2 v0.1.3 github.com/spyzhov/ajson v0.9.0 @@ -73,7 +73,7 @@ require ( github.com/sagernet/quic-go v0.0.0-20230825040534-0cd917b2ddda // indirect github.com/sagernet/reality v0.0.0-20230406110435-ee17307e7691 // indirect github.com/sagernet/sing-dns v0.1.9-0.20230824120133-4d5cbceb40c1 // indirect - github.com/sagernet/sing-mux v0.1.3-0.20230811111955-dc1639b5204c // indirect + github.com/sagernet/sing-mux v0.1.3-0.20230830095209-2a10ebd53ba8 // indirect github.com/sagernet/sing-shadowtls v0.1.4 // indirect github.com/sagernet/sing-tun v0.1.12-0.20230821065522-7545dc2d5641 // indirect github.com/sagernet/sing-vmess v0.1.7 // indirect diff --git a/test/go.sum b/test/go.sum index 6cbdf320..544e35cb 100644 --- a/test/go.sum +++ b/test/go.sum @@ -134,11 +134,13 @@ github.com/sagernet/sing v0.1.8/go.mod h1:jt1w2u7lJQFFSGLiRrRIs5YWmx4kAPfWuOejuD github.com/sagernet/sing v0.2.10-0.20230821073500-620f3a3b882d h1:4kgoOCE48CuQcBUcoRnE0QTPXkl8yM8i7Nipmzp/978= github.com/sagernet/sing v0.2.10-0.20230821073500-620f3a3b882d/go.mod h1:9uOZwWkhT2Z2WldolLxX34s+1svAX4i4vvz5hy8u1MA= github.com/sagernet/sing v0.2.10-0.20230824115837-8d731e68853a/go.mod h1:9uOZwWkhT2Z2WldolLxX34s+1svAX4i4vvz5hy8u1MA= +github.com/sagernet/sing v0.2.10-0.20230830132630-30bf19f2833c/go.mod h1:9uOZwWkhT2Z2WldolLxX34s+1svAX4i4vvz5hy8u1MA= github.com/sagernet/sing-dns v0.1.9-0.20230731012726-ad50da89b659 h1:1DAKccGNqTYJ8nsBR765FS0LVBVXfuFlFAHqKsGN3EI= github.com/sagernet/sing-dns v0.1.9-0.20230731012726-ad50da89b659/go.mod h1:W7GHTZFS8RkoLI3bA2LFY27/0E+uoQESWtMFLepO/JA= github.com/sagernet/sing-dns v0.1.9-0.20230824120133-4d5cbceb40c1/go.mod h1:Kg98PBJEg/08jsNFtmZWmPomhskn9Ausn50ecNm4M+8= github.com/sagernet/sing-mux v0.1.3-0.20230811111955-dc1639b5204c h1:35/FowAvt3Z62mck0TXzVc4jS5R5CWq62qcV2P1cp0I= github.com/sagernet/sing-mux v0.1.3-0.20230811111955-dc1639b5204c/go.mod h1:TKxqIvfQQgd36jp2tzsPavGjYTVZilV+atip1cssjIY= +github.com/sagernet/sing-mux v0.1.3-0.20230830095209-2a10ebd53ba8/go.mod h1:TKxqIvfQQgd36jp2tzsPavGjYTVZilV+atip1cssjIY= github.com/sagernet/sing-shadowsocks v0.2.4 h1:s/CqXlvFAZhlIoHWUwPw5CoNnQ9Ibki9pckjuugtVfY= github.com/sagernet/sing-shadowsocks v0.2.4/go.mod h1:80fNKP0wnqlu85GZXV1H1vDPC/2t+dQbFggOw4XuFUM= github.com/sagernet/sing-shadowsocks2 v0.1.3 h1:WXoLvCFi5JTFBRYorf1YePGYIQyJ/zbsBM6Fwbl5kGA= diff --git a/transport/hysteria/protocol.go b/transport/hysteria/protocol.go index 1e516f6d..a338988f 100644 --- a/transport/hysteria/protocol.go +++ b/transport/hysteria/protocol.go @@ -394,7 +394,7 @@ func (c *Conn) Read(p []byte) (n int, err error) { } func (c *Conn) LocalAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *Conn) RemoteAddr() net.Addr { @@ -502,7 +502,7 @@ func (c *PacketConn) WriteTo(p []byte, addr net.Addr) (n int, err error) { } func (c *PacketConn) LocalAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *PacketConn) RemoteAddr() net.Addr { diff --git a/transport/v2raygrpc/conn.go b/transport/v2raygrpc/conn.go index b437f04c..821eac70 100644 --- a/transport/v2raygrpc/conn.go +++ b/transport/v2raygrpc/conn.go @@ -7,6 +7,7 @@ import ( "github.com/sagernet/sing-box/common/baderror" "github.com/sagernet/sing/common" + M "github.com/sagernet/sing/common/metadata" "github.com/sagernet/sing/common/rw" ) @@ -62,11 +63,11 @@ func (c *GRPCConn) Close() error { } func (c *GRPCConn) LocalAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *GRPCConn) RemoteAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *GRPCConn) SetDeadline(t time.Time) error { diff --git a/transport/v2raygrpclite/conn.go b/transport/v2raygrpclite/conn.go index fd6f36d3..d2f36f42 100644 --- a/transport/v2raygrpclite/conn.go +++ b/transport/v2raygrpclite/conn.go @@ -15,6 +15,7 @@ import ( "github.com/sagernet/sing/common" "github.com/sagernet/sing/common/buf" "github.com/sagernet/sing/common/bufio" + M "github.com/sagernet/sing/common/metadata" "github.com/sagernet/sing/common/rw" ) @@ -138,7 +139,7 @@ func (c *GunConn) Close() error { } func (c *GunConn) LocalAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *GunConn) RemoteAddr() net.Addr { diff --git a/transport/v2rayhttp/conn.go b/transport/v2rayhttp/conn.go index 27f88134..8fa4ee84 100644 --- a/transport/v2rayhttp/conn.go +++ b/transport/v2rayhttp/conn.go @@ -16,6 +16,7 @@ import ( "github.com/sagernet/sing/common/bufio" E "github.com/sagernet/sing/common/exceptions" F "github.com/sagernet/sing/common/format" + M "github.com/sagernet/sing/common/metadata" N "github.com/sagernet/sing/common/network" ) @@ -174,11 +175,11 @@ func (c *HTTP2Conn) Close() error { } func (c *HTTP2Conn) LocalAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *HTTP2Conn) RemoteAddr() net.Addr { - return nil + return M.Socksaddr{} } func (c *HTTP2Conn) SetDeadline(t time.Time) error {