Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed May 11, 2022
1 parent c40fe4f commit 216cac4
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 36 deletions.
2 changes: 1 addition & 1 deletion core.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import (
)

var (
version = "5.0.9"
version = "5.0.10"
build = "SagerNet"
codename = "V2Fly, a community-driven edition of V2Ray."
intro = "A unified platform for anti-censorship."
Expand Down
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ require (
github.com/kierdavis/cfb8 v0.0.0-20180105024805-3a17c36ee2f8
github.com/lucas-clemente/quic-go v0.27.0
github.com/marten-seemann/qtls-go1-17 v0.1.1
github.com/miekg/dns v1.1.48
github.com/miekg/dns v1.1.49
github.com/mustafaturan/bus v1.0.2
github.com/pires/go-proxyproto v0.6.2
github.com/sagernet/sing v0.0.0-20220508121227-dd16e8fbe60f
github.com/sagernet/sing v0.0.0-20220511221614-b1ce47aacaee
github.com/seiflotfy/cuckoofilter v0.0.0-20220411075957-e3b120b3f5fb
github.com/stretchr/testify v1.7.1
github.com/v2fly/BrowserBridge v0.0.0-20210430233438-0570fc1d7d08
Expand All @@ -31,7 +31,7 @@ require (
github.com/xiaokangwang/VLite v0.0.0-20220418190619-cff95160a432
github.com/xtls/go v0.0.0-20210920065950-d4af136d3672
go.starlark.net v0.0.0-20220328144851-d1966c6b9fcd
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6
Expand Down Expand Up @@ -81,7 +81,6 @@ require (
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect
github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4 // indirect
github.com/sirupsen/logrus v1.8.1 // indirect
github.com/xtaci/smux v1.5.16 // indirect
go4.org/intern v0.0.0-20220301175310-a089fc204883 // indirect
go4.org/unsafe/assume-no-moving-gc v0.0.0-20211027215541-db492cf91b37 // indirect
Expand Down
15 changes: 6 additions & 9 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -270,8 +270,8 @@ github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNx
github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.48 h1:Ucfr7IIVyMBz4lRE8qmGUuZ4Wt3/ZGu9hmcMT3Uu4tQ=
github.com/miekg/dns v1.1.48/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
github.com/miekg/dns v1.1.49 h1:qe0mQU3Z/XpFeE+AEBo2rqaS1IPBJ3anmqZ4XiZJVG8=
github.com/miekg/dns v1.1.49/go.mod h1:e3IlAVfNqAllflbibAZEWOXOQ+Ynzk/dDozDxY7XnME=
github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc=
github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0=
Expand Down Expand Up @@ -357,8 +357,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
github.com/sagernet/gvisor v0.0.0-20220402114650-763d12dc953e h1:Y4avBAtZ59OWvLl6zP9sF62jtMEVRPIH78IQctq9aXQ=
github.com/sagernet/gvisor v0.0.0-20220402114650-763d12dc953e/go.mod h1:tWwEcFvJavs154OdjFCw78axNrsDlz4Zh8jvPqwcpGI=
github.com/sagernet/sing v0.0.0-20220508121227-dd16e8fbe60f h1:V0UJ3/V8AgOShLCGdcFG0ELtk/rKLJ2dfh1NG3UpUts=
github.com/sagernet/sing v0.0.0-20220508121227-dd16e8fbe60f/go.mod h1:NumELwhD4Wv5j09XQ6s97isM7S4oFKsCdVrgJeM24zE=
github.com/sagernet/sing v0.0.0-20220511221614-b1ce47aacaee h1:N+EhRb81eqLbUcIYsd2tB8ksgDr7YeoIjuwhfywPDTI=
github.com/sagernet/sing v0.0.0-20220511221614-b1ce47aacaee/go.mod h1:VwWKzsa5GIx/hqqPbbbcpb33g82m6UTXz1nsPwxE4J0=
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4 h1:zOjq+1/uLzn/Xo40stbvjIY/yehG0+mfmlsiEmc0xmQ=
github.com/secure-io/siv-go v0.0.0-20180922214919-5ff40651e2c4/go.mod h1:aI+8yClBW+1uovkHw6HM01YXnYB8vohtB9C83wzx34E=
Expand Down Expand Up @@ -392,8 +392,6 @@ github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeV
github.com/shurcooL/users v0.0.0-20180125191416-49c67e49c537/go.mod h1:QJTqeLYEDaXHZDBsXlPCDqdhQuJkuw4NOtaxYe3xii4=
github.com/shurcooL/webdavfs v0.0.0-20170829043945-18c3829fa133/go.mod h1:hKmq5kWdCj2z2KEozexVbfEZIWiTjhE0+UjmZgPqehw=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/sirupsen/logrus v1.8.1 h1:dJKuHgqk1NNQlqoA6BTlM1Wf9DOH3NBjQyu0h9+AZZE=
github.com/sirupsen/logrus v1.8.1/go.mod h1:yWOB1SBYBC5VeMP7gHvWumXLIWorT60ONWic61uBYv0=
github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc=
github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA=
github.com/soheilhy/cmux v0.1.4/go.mod h1:IM3LyeVVIOuxMH7sFAkER9+bJ4dT7Ms6E4xg4kGIyLM=
Expand Down Expand Up @@ -474,8 +472,8 @@ golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122 h1:NvGWuYG8dkDHFSKksI1P9faiVJ9rayE6l0+ouWVIDs8=
golang.org/x/crypto v0.0.0-20220507011949-2cf3adece122/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88 h1:Tgea0cVUD0ivh5ADBX4WwuI12DUd2to3nCYe2eayMIw=
golang.org/x/crypto v0.0.0-20220511200225-c6db032c6c88/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8=
Expand Down Expand Up @@ -565,7 +563,6 @@ golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
29 changes: 19 additions & 10 deletions proxy/shadowsocks_sing/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,13 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Outbound, error) {
}
key = bKdy
}
rng := random.Blake3KeyedHash().Reader
var rng io.Reader = random.Default
if config.ReducedIvHeadEntropy {
rng = &shadowsocks.ReducedEntropyReader{
Reader: rng,
}
}
method, err := shadowaead.New(config.Method, key, []byte(config.Password), rng, false)
method, err := shadowaead.New(config.Method, key, []byte(config.Password), rng)
if err != nil {
return nil, newError("create method").Base(err)
}
Expand All @@ -90,7 +90,7 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Outbound, error) {
copy(psk[:], kb)
pskList = append(pskList, psk)
}
rng := random.Blake3KeyedHash().Reader
var rng io.Reader = random.Default
if config.ReducedIvHeadEntropy {
rng = &shadowsocks.ReducedEntropyReader{
Reader: rng,
Expand Down Expand Up @@ -227,10 +227,11 @@ func (o *Outbound) Process(ctx context.Context, link *transport.Link, dialer int
packetConn = &N.PacketConnWrapper{PacketConn: nc}
} else {
packetConn = &PacketConnWrapper{
Reader: link.Reader,
Writer: link.Writer,
Conn: inboundConn,
Dest: destination,
Reader: link.Reader,
Writer: link.Writer,
PipeOut: pipe.IsPipe(link.Writer),
Conn: inboundConn,
Dest: destination,
}
}

Expand Down Expand Up @@ -342,6 +343,7 @@ func (w *PipeConnWrapper) Write(p []byte) (n int, err error) {
buffer := buf.New()
_, err = buffer.Write(p)
if err != nil {
buffer.Release()
return
}
err = w.W.WriteMultiBuffer(buf.MultiBuffer{buffer})
Expand All @@ -363,8 +365,9 @@ type PacketConnWrapper struct {
buf.Reader
buf.Writer
net.Conn
Dest net.Destination
cached buf.MultiBuffer
PipeOut bool
Dest net.Destination
cached buf.MultiBuffer
}

func (w *PacketConnWrapper) ReadPacket(buffer *B.Buffer) (M.Socksaddr, error) {
Expand Down Expand Up @@ -407,7 +410,13 @@ func (w *PacketConnWrapper) ReadPacket(buffer *B.Buffer) (M.Socksaddr, error) {
}

func (w *PacketConnWrapper) WritePacket(buffer *B.Buffer, addrPort M.Socksaddr) error {
vBuf := buf.FromBytes(buffer.Bytes())
var vBuf *buf.Buffer
if w.PipeOut {
vBuf = buf.New()
vBuf.Write(buffer.Bytes())
} else {
vBuf = buf.FromBytes(buffer.Bytes())
}
endpoint := net.DestinationFromAddr(addrPort.UDPAddr())
vBuf.Endpoint = &endpoint
return w.Writer.WriteMultiBuffer(buf.MultiBuffer{vBuf})
Expand Down
17 changes: 9 additions & 8 deletions proxy/ssh/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
c.Lock()
sc = c.client
if c.client == nil {
client, err := c.connect(ctx, dialer)
conn, client, err := c.connect(ctx, dialer)
if err != nil {
return err
}
connElem := net.AddConnection(client)
connElem := net.AddConnection(conn)
go func() {
err = client.Wait()
if err != nil {
Expand Down Expand Up @@ -202,11 +202,11 @@ func (c *Client) ProcessConn(ctx context.Context, conn net.Conn, dialer internet
c.Lock()
sc = c.client
if c.client == nil {
client, err := c.connect(ctx, dialer)
conn, client, err := c.connect(ctx, dialer)
if err != nil {
return err
}
connElem := net.AddConnection(client)
connElem := net.AddConnection(conn)
go func() {
err = client.Wait()
if err != nil {
Expand All @@ -230,7 +230,7 @@ func (c *Client) ProcessConn(ctx context.Context, conn net.Conn, dialer internet
return rw.CopyConn(ctx, conn, outboundConn)
}

func (c *Client) connect(ctx context.Context, dialer internet.Dialer) (*ssh.Client, error) {
func (c *Client) connect(ctx context.Context, dialer internet.Dialer) (net.Conn, *ssh.Client, error) {
config := &ssh.ClientConfig{
User: c.config.User,
Auth: c.auth,
Expand All @@ -257,17 +257,18 @@ func (c *Client) connect(ctx context.Context, dialer internet.Dialer) (*ssh.Clie
return nil
})
if err != nil {
return nil, newError("failed to connect to ssh server").AtWarning().Base(err)
return nil, nil, newError("failed to connect to ssh server").AtWarning().Base(err)
}

clientConn, chans, reqs, err := ssh.NewClientConn(conn, c.server.Address.String(), config)
if err != nil {
return nil, newError("failed to create ssh connection").Base(err)
conn.Close()
return nil, nil, newError("failed to create ssh connection").Base(err)
}

client := ssh.NewClient(clientConn, chans, reqs)
c.client = client
return client, nil
return conn, client, nil
}

func (c *Client) Close() error {
Expand Down
9 changes: 5 additions & 4 deletions proxy/trojan_sing/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -288,10 +288,11 @@ func (c *Client) Process(ctx context.Context, link *transport.Link, dialer inter
packetConn = pc
} else {
packetConn = &shadowsocks_sing.PacketConnWrapper{
Reader: link.Reader,
Writer: link.Writer,
Conn: inboundConn,
Dest: destination,
Reader: link.Reader,
Writer: link.Writer,
PipeOut: pipe.IsPipe(link.Writer),
Conn: inboundConn,
Dest: destination,
}
}

Expand Down

0 comments on commit 216cac4

Please sign in to comment.