Fix buffer usage

This commit is contained in:
世界 2022-08-02 13:43:25 +08:00
parent 37b11e614c
commit b1c2440371
No known key found for this signature in database
GPG key ID: CD109927C34A63C4
8 changed files with 46 additions and 61 deletions

12
go.mod
View file

@ -13,17 +13,17 @@ require (
github.com/hashicorp/yamux v0.1.1 github.com/hashicorp/yamux v0.1.1
github.com/logrusorgru/aurora v2.0.3+incompatible github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/oschwald/maxminddb-golang v1.9.0 github.com/oschwald/maxminddb-golang v1.9.0
github.com/sagernet/sing v0.0.0-20220731103035-5ea209cbb795 github.com/sagernet/sing v0.0.0-20220802021749-842fd713ff94
github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9 github.com/sagernet/sing-dns v0.0.0-20220801112436-b9e99d83271e
github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8 github.com/sagernet/sing-shadowsocks v0.0.0-20220801112336-a91eacdd01e1
github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 github.com/sagernet/sing-tun v0.0.0-20220801125145-69bc471e19ac
github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a github.com/sagernet/sing-vmess v0.0.0-20220802053753-a38d3b22e6b9
github.com/spf13/cobra v1.5.0 github.com/spf13/cobra v1.5.0
github.com/stretchr/testify v1.8.0 github.com/stretchr/testify v1.8.0
go.uber.org/atomic v1.9.0 go.uber.org/atomic v1.9.0
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 golang.org/x/net v0.0.0-20220728211354-c7608f3a8462
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 golang.org/x/sys v0.0.0-20220731174439-a90be440212d
) )
// TODO: remove after upstream fixed // TODO: remove after upstream fixed

24
go.sum
View file

@ -149,16 +149,16 @@ github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7q
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sagernet/sing v0.0.0-20220731103035-5ea209cbb795 h1:hlSvZBH0Y5KdFo4dvy4FWjg2pDjj6YJegp6zDgr/KlQ= github.com/sagernet/sing v0.0.0-20220802021749-842fd713ff94 h1:AEsJjN5cOy9/ILWPBQU2AljGqLjyeKHw4yJmp90rPI4=
github.com/sagernet/sing v0.0.0-20220731103035-5ea209cbb795/go.mod h1:GbtQfZSpmtD3cXeD1qX2LCMwY8dH+bnnInDTqd92IsM= github.com/sagernet/sing v0.0.0-20220802021749-842fd713ff94/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY=
github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9 h1:2xg2bzELWQyaD5QwS3QV90RLWqjL8d6LQmKNWOI8XWQ= github.com/sagernet/sing-dns v0.0.0-20220801112436-b9e99d83271e h1:bkAQ07NmD2vvEg1r/VrKr63BeJXQqZP29waU1Lr1XBM=
github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9/go.mod h1:ZSslb2fc27A1Tk3WM5yootwWLSglsxqRZv3noam5pso= github.com/sagernet/sing-dns v0.0.0-20220801112436-b9e99d83271e/go.mod h1:4pEktidzm9Aq9QaN0TuwhOTYD2nFSPsoXckG4svKz/Q=
github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8 h1:d6Sda+GXFRvKwRlE9fiwC32p1/vEVArZ7PgvyCg9TAI= github.com/sagernet/sing-shadowsocks v0.0.0-20220801112336-a91eacdd01e1 h1:RYvOc69eSNMN0dwVugrDts41Nn7Ar/C/n/fvytvFcp4=
github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8/go.mod h1:aNTIkd+bCIUgr5C43aZBGXDxIc0Y9NOozLLzH2vUydM= github.com/sagernet/sing-shadowsocks v0.0.0-20220801112336-a91eacdd01e1/go.mod h1:NqZjiXszgVCMQ4gVDa2V+drhS8NMfGqUqDF86EacEFc=
github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 h1:xXpkIml1GbkNlQwlmdLWvXBmOBPHDEIjv/QSrKPsLgY= github.com/sagernet/sing-tun v0.0.0-20220801125145-69bc471e19ac h1:ciP+7vbPng9QDHB1NmW0M33VyEifPL0wbVfB0FDetSk=
github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8/go.mod h1:1V/Scct3DGHi925AasPCj1k+6SRWIcg0TvRHM0ZXB8I= github.com/sagernet/sing-tun v0.0.0-20220801125145-69bc471e19ac/go.mod h1:1V/Scct3DGHi925AasPCj1k+6SRWIcg0TvRHM0ZXB8I=
github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a h1:U4I/CHpGposYUF6RkQjzixr93ww2trnFJDo7JhFrBY0= github.com/sagernet/sing-vmess v0.0.0-20220802053753-a38d3b22e6b9 h1:x+r8P5MKyQWGN3tcI5dmOM1Aei1mlWua2ciMBGz0/oM=
github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a/go.mod h1:4/SUIlK6Xn+hT7srzTcqVFQ/jX3EX4y3nYDfP0BnAuk= github.com/sagernet/sing-vmess v0.0.0-20220802053753-a38d3b22e6b9/go.mod h1:ETvczg3TQzGa8zg0lYXj8cYTJr4+OFUmtQer9/c/cLU=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY=
github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM=
@ -279,8 +279,8 @@ golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 h1:aNCnH+Fiqs7ZDTFH6oEFjIfbX2HvgQXJ6uQuUbTobjk= golang.org/x/sys v0.0.0-20220731174439-a90be440212d h1:Sv5ogFZatcgIMMtBSTTAgMYsicp25MXBubjXNDKwm80=
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220731174439-a90be440212d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View file

@ -133,12 +133,10 @@ func (d *DNS) NewPacketConnection(ctx context.Context, conn N.PacketConn, metada
return err return err
} }
timeout.Update() timeout.Update()
_responseBuffer := buf.StackNewPacket() responseBuffer := buf.NewPacket()
defer common.KeepAlive(_responseBuffer)
responseBuffer := common.Dup(_responseBuffer)
defer responseBuffer.Release()
n, err := response.AppendPack(responseBuffer.Index(0)) n, err := response.AppendPack(responseBuffer.Index(0))
if err != nil { if err != nil {
responseBuffer.Release()
return err return err
} }
responseBuffer.Truncate(len(n)) responseBuffer.Truncate(len(n))

View file

@ -492,10 +492,8 @@ func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata ad
return mux.NewConnection(ctx, r, r, r.logger, conn, metadata) return mux.NewConnection(ctx, r, r, r.logger, conn, metadata)
} }
if metadata.SniffEnabled { if metadata.SniffEnabled {
_buffer := buf.StackNew() buffer := buf.NewPacket()
defer common.KeepAlive(_buffer) buffer.FullReset()
buffer := common.Dup(_buffer)
defer buffer.Release()
sniffMetadata, err := sniff.PeekStream(ctx, conn, buffer, sniff.StreamDomainNameQuery, sniff.TLSClientHello, sniff.HTTPHost) sniffMetadata, err := sniff.PeekStream(ctx, conn, buffer, sniff.StreamDomainNameQuery, sniff.TLSClientHello, sniff.HTTPHost)
if err == nil { if err == nil {
metadata.Protocol = sniffMetadata.Protocol metadata.Protocol = sniffMetadata.Protocol
@ -511,6 +509,8 @@ func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata ad
} }
if !buffer.IsEmpty() { if !buffer.IsEmpty() {
conn = bufio.NewCachedConn(conn, buffer) conn = bufio.NewCachedConn(conn, buffer)
} else {
buffer.Release()
} }
} }
if metadata.Destination.IsFqdn() && metadata.DomainStrategy != dns.DomainStrategyAsIS { if metadata.Destination.IsFqdn() && metadata.DomainStrategy != dns.DomainStrategyAsIS {
@ -536,12 +536,11 @@ func (r *Router) RouteConnection(ctx context.Context, conn net.Conn, metadata ad
func (r *Router) RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata adapter.InboundContext) error { func (r *Router) RoutePacketConnection(ctx context.Context, conn N.PacketConn, metadata adapter.InboundContext) error {
if metadata.SniffEnabled { if metadata.SniffEnabled {
_buffer := buf.StackNewPacket() buffer := buf.NewPacket()
defer common.KeepAlive(_buffer) buffer.FullReset()
buffer := common.Dup(_buffer)
defer buffer.Release()
_, err := conn.ReadPacket(buffer) _, err := conn.ReadPacket(buffer)
if err != nil { if err != nil {
buffer.Release()
return err return err
} }
sniffMetadata, err := sniff.PeekPacket(ctx, buffer.Bytes(), sniff.DomainNameQuery, sniff.QUICClientHello, sniff.STUNMessage) sniffMetadata, err := sniff.PeekPacket(ctx, buffer.Bytes(), sniff.DomainNameQuery, sniff.QUICClientHello, sniff.STUNMessage)

View file

@ -10,8 +10,8 @@ require (
github.com/docker/docker v20.10.17+incompatible github.com/docker/docker v20.10.17+incompatible
github.com/docker/go-connections v0.4.0 github.com/docker/go-connections v0.4.0
github.com/gofrs/uuid v4.2.0+incompatible github.com/gofrs/uuid v4.2.0+incompatible
github.com/sagernet/sing v0.0.0-20220731103035-5ea209cbb795 github.com/sagernet/sing v0.0.0-20220802021749-842fd713ff94
github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8 github.com/sagernet/sing-shadowsocks v0.0.0-20220801112336-a91eacdd01e1
github.com/spyzhov/ajson v0.7.1 github.com/spyzhov/ajson v0.7.1
github.com/stretchr/testify v1.8.0 github.com/stretchr/testify v1.8.0
golang.org/x/net v0.0.0-20220728211354-c7608f3a8462 golang.org/x/net v0.0.0-20220728211354-c7608f3a8462
@ -52,16 +52,16 @@ require (
github.com/oschwald/maxminddb-golang v1.9.0 // indirect github.com/oschwald/maxminddb-golang v1.9.0 // indirect
github.com/pkg/errors v0.9.1 // indirect github.com/pkg/errors v0.9.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9 // indirect github.com/sagernet/sing-dns v0.0.0-20220801112436-b9e99d83271e // indirect
github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 // indirect github.com/sagernet/sing-tun v0.0.0-20220801125145-69bc471e19ac // indirect
github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a // indirect github.com/sagernet/sing-vmess v0.0.0-20220802053753-a38d3b22e6b9 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect github.com/sirupsen/logrus v1.8.1 // indirect
github.com/vishvananda/netlink v1.1.0 // indirect github.com/vishvananda/netlink v1.1.0 // indirect
github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect github.com/vishvananda/netns v0.0.0-20211101163701-50045581ed74 // indirect
go.uber.org/atomic v1.9.0 // indirect go.uber.org/atomic v1.9.0 // indirect
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa // indirect
golang.org/x/mod v0.5.1 // indirect golang.org/x/mod v0.5.1 // indirect
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 // indirect golang.org/x/sys v0.0.0-20220731174439-a90be440212d // indirect
golang.org/x/text v0.3.7 // indirect golang.org/x/text v0.3.7 // indirect
golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect golang.org/x/time v0.0.0-20191024005414-555d28b269f0 // indirect
golang.org/x/tools v0.1.9 // indirect golang.org/x/tools v0.1.9 // indirect

View file

@ -172,16 +172,16 @@ github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:
github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro= github.com/prometheus/common v0.0.0-20180801064454-c7de2306084e/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.0-20180725123919-05ee40e3a273/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g= github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/sagernet/sing v0.0.0-20220731103035-5ea209cbb795 h1:hlSvZBH0Y5KdFo4dvy4FWjg2pDjj6YJegp6zDgr/KlQ= github.com/sagernet/sing v0.0.0-20220802021749-842fd713ff94 h1:AEsJjN5cOy9/ILWPBQU2AljGqLjyeKHw4yJmp90rPI4=
github.com/sagernet/sing v0.0.0-20220731103035-5ea209cbb795/go.mod h1:GbtQfZSpmtD3cXeD1qX2LCMwY8dH+bnnInDTqd92IsM= github.com/sagernet/sing v0.0.0-20220802021749-842fd713ff94/go.mod h1:QVsS5L/ZA2Q5UhQwLrn0Trw+msNd/NPGEhBKR/ioWiY=
github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9 h1:2xg2bzELWQyaD5QwS3QV90RLWqjL8d6LQmKNWOI8XWQ= github.com/sagernet/sing-dns v0.0.0-20220801112436-b9e99d83271e h1:bkAQ07NmD2vvEg1r/VrKr63BeJXQqZP29waU1Lr1XBM=
github.com/sagernet/sing-dns v0.0.0-20220730061139-c8e0fb296da9/go.mod h1:ZSslb2fc27A1Tk3WM5yootwWLSglsxqRZv3noam5pso= github.com/sagernet/sing-dns v0.0.0-20220801112436-b9e99d83271e/go.mod h1:4pEktidzm9Aq9QaN0TuwhOTYD2nFSPsoXckG4svKz/Q=
github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8 h1:d6Sda+GXFRvKwRlE9fiwC32p1/vEVArZ7PgvyCg9TAI= github.com/sagernet/sing-shadowsocks v0.0.0-20220801112336-a91eacdd01e1 h1:RYvOc69eSNMN0dwVugrDts41Nn7Ar/C/n/fvytvFcp4=
github.com/sagernet/sing-shadowsocks v0.0.0-20220730132258-5c45f99276b8/go.mod h1:aNTIkd+bCIUgr5C43aZBGXDxIc0Y9NOozLLzH2vUydM= github.com/sagernet/sing-shadowsocks v0.0.0-20220801112336-a91eacdd01e1/go.mod h1:NqZjiXszgVCMQ4gVDa2V+drhS8NMfGqUqDF86EacEFc=
github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8 h1:xXpkIml1GbkNlQwlmdLWvXBmOBPHDEIjv/QSrKPsLgY= github.com/sagernet/sing-tun v0.0.0-20220801125145-69bc471e19ac h1:ciP+7vbPng9QDHB1NmW0M33VyEifPL0wbVfB0FDetSk=
github.com/sagernet/sing-tun v0.0.0-20220731115551-4a805410a2e8/go.mod h1:1V/Scct3DGHi925AasPCj1k+6SRWIcg0TvRHM0ZXB8I= github.com/sagernet/sing-tun v0.0.0-20220801125145-69bc471e19ac/go.mod h1:1V/Scct3DGHi925AasPCj1k+6SRWIcg0TvRHM0ZXB8I=
github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a h1:U4I/CHpGposYUF6RkQjzixr93ww2trnFJDo7JhFrBY0= github.com/sagernet/sing-vmess v0.0.0-20220802053753-a38d3b22e6b9 h1:x+r8P5MKyQWGN3tcI5dmOM1Aei1mlWua2ciMBGz0/oM=
github.com/sagernet/sing-vmess v0.0.0-20220801082718-0b96d703437a/go.mod h1:4/SUIlK6Xn+hT7srzTcqVFQ/jX3EX4y3nYDfP0BnAuk= github.com/sagernet/sing-vmess v0.0.0-20220802053753-a38d3b22e6b9/go.mod h1:ETvczg3TQzGa8zg0lYXj8cYTJr4+OFUmtQer9/c/cLU=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY= github.com/shurcooL/component v0.0.0-20170202220835-f88ec8f54cc4/go.mod h1:XhFIlyj5a1fBNx5aJTbKoIq0mNaPvOagO+HjB3EtxrY=
github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM= github.com/shurcooL/events v0.0.0-20181021180414-410e4ca65f48/go.mod h1:5u70Mqkb5O5cxEA8nxTsgrgLehJeAw6Oc4Ab1c/P1HM=
@ -314,8 +314,8 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39 h1:aNCnH+Fiqs7ZDTFH6oEFjIfbX2HvgQXJ6uQuUbTobjk= golang.org/x/sys v0.0.0-20220731174439-a90be440212d h1:Sv5ogFZatcgIMMtBSTTAgMYsicp25MXBubjXNDKwm80=
golang.org/x/sys v0.0.0-20220730100132-1609e554cd39/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220731174439-a90be440212d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=

View file

@ -14,7 +14,7 @@ func TestShadowsocksMux(t *testing.T) {
password := mkBase64(t, 16) password := mkBase64(t, 16)
startInstance(t, option.Options{ startInstance(t, option.Options{
Log: &option.LogOptions{ Log: &option.LogOptions{
Level: "debug", Level: "error",
}, },
Inbounds: []option.Inbound{ Inbounds: []option.Inbound{
{ {

View file

@ -36,27 +36,15 @@ func testVMess0(t *testing.T, security string) {
t.Run("self", func(t *testing.T) { t.Run("self", func(t *testing.T) {
testVMessSelf(t, security, user, 0, false, false) testVMessSelf(t, security, user, 0, false, false)
}) })
t.Run("self-padding", func(t *testing.T) {
testVMessSelf(t, security, user, 0, true, false)
})
t.Run("self-legacy", func(t *testing.T) { t.Run("self-legacy", func(t *testing.T) {
testVMessSelf(t, security, user, 1, false, false) testVMessSelf(t, security, user, 1, false, false)
}) })
t.Run("self-legacy-padding", func(t *testing.T) {
testVMessSelf(t, security, user, 1, true, false)
})
t.Run("outbound", func(t *testing.T) { t.Run("outbound", func(t *testing.T) {
testVMessOutboundWithV2Ray(t, security, user, false, false, 0) testVMessOutboundWithV2Ray(t, security, user, false, false, 0)
}) })
t.Run("outbound-padding", func(t *testing.T) {
testVMessOutboundWithV2Ray(t, security, user, true, false, 0)
})
t.Run("outbound-legacy", func(t *testing.T) { t.Run("outbound-legacy", func(t *testing.T) {
testVMessOutboundWithV2Ray(t, security, user, false, false, 1) testVMessOutboundWithV2Ray(t, security, user, false, false, 1)
}) })
t.Run("outbound-legacy-padding", func(t *testing.T) {
testVMessOutboundWithV2Ray(t, security, user, true, false, 1)
})
} }
func testVMess1(t *testing.T, security string) { func testVMess1(t *testing.T, security string) {