Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nekohasekai committed May 14, 2022
1 parent 2b40871 commit d5d6a0c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 63 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.10"
version = "5.0.14"
build = "SagerNet"
codename = "V2Fly, a community-driven edition of V2Ray."
intro = "A unified platform for anti-censorship."
Expand Down
12 changes: 5 additions & 7 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ require (
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-20220512055044-f1a5f8aaa3c6
github.com/sagernet/sing v0.0.0-20220514073534-7d06e20837ac
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,10 +31,10 @@ 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-20220511200225-c6db032c6c88
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4
golang.org/x/crypto v0.0.0-20220513210258-46612604a0f9
golang.org/x/net v0.0.0-20220513224357-95641704303c
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a
golang.zx2c4.com/wireguard v0.0.0-20220407013110-ef5c587f782d
google.golang.org/grpc v1.46.0
google.golang.org/protobuf v1.28.0
Expand All @@ -44,14 +44,11 @@ require (
lukechampine.com/blake3 v1.1.7
)

require github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect

// https://github.com/google/gvisor/releases/tag/release-20220314.0
replace gvisor.dev/gvisor => github.com/sagernet/gvisor v0.0.0-20220402114650-763d12dc953e

//replace github.com/sagernet/sing => ../sing

//
require (
github.com/aead/cmac v0.0.0-20160719120800-7af84192f0b1 // indirect
github.com/boljen/go-bitmap v0.0.0-20151001105940-23cd2fb0ce7d // indirect
Expand All @@ -71,6 +68,7 @@ require (
github.com/leodido/go-urn v1.2.1 // indirect
github.com/lunixbochs/struc v0.0.0-20200707160740-784aaebc1d40 // indirect
github.com/marten-seemann/qtls-go1-16 v0.1.5 // indirect
github.com/marten-seemann/qtls-go1-17 v0.1.1 // indirect
github.com/mustafaturan/monoton v1.0.0 // indirect
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
Expand Down
9 changes: 7 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,10 @@ 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-20220512055044-f1a5f8aaa3c6 h1:5xDtCbrv5ZBErp/A+3iEfpHllTLrDQFGTf0PKoyDW/s=
github.com/sagernet/sing v0.0.0-20220512055044-f1a5f8aaa3c6/go.mod h1:VwWKzsa5GIx/hqqPbbbcpb33g82m6UTXz1nsPwxE4J0=
github.com/sagernet/sing v0.0.0-20220514071652-f17d3036cd5a h1:F6Th+eKg4G/aTgUiR780SQ9PNbtFH0t/RU5rPhlUvII=
github.com/sagernet/sing v0.0.0-20220514071652-f17d3036cd5a/go.mod h1:VwWKzsa5GIx/hqqPbbbcpb33g82m6UTXz1nsPwxE4J0=
github.com/sagernet/sing v0.0.0-20220514073534-7d06e20837ac h1:lbDLlbLUj+BINsaFPIpLwms+uvZmbNThvwtIubOLjMU=
github.com/sagernet/sing v0.0.0-20220514073534-7d06e20837ac/go.mod h1:dHpfb6iNd7Mt/DGl/jE0rRV25vImjVqmah61iTdY4bo=
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 @@ -474,6 +476,7 @@ golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm
golang.org/x/crypto v0.0.0-20211215153901-e495a2d5b3d3/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/crypto v0.0.0-20220513210258-46612604a0f9/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 @@ -528,6 +531,7 @@ golang.org/x/net v0.0.0-20210726213435-c6fcb2dbf985/go.mod h1:9nx3DQGgdP8bBQD5qx
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4 h1:HVyaeDAYux4pnY+D/SiwmLOR36ewZ4iGQIIrtnuCjFA=
golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/net v0.0.0-20220513224357-95641704303c/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181017192945-9dcd33a902f4/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/oauth2 v0.0.0-20181203162652-d668ce993890/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
Expand Down Expand Up @@ -580,6 +584,7 @@ golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBc
golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6 h1:nonptSpoQ4vQjyraW20DXPAglgQfVnM9ZC6MmNLMR60=
golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220513210249-45d2b4557a2a/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-20210927222741-03fcf44c2211 h1:JGgROgKl9N8DuW20oFS5gxc+lE67/N3FcwmBPMe7ArY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
Expand Down
63 changes: 10 additions & 53 deletions proxy/shadowsocks_sing/outbound.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ package shadowsocks_sing

import (
"context"
"encoding/base64"
"io"
"runtime"
"strings"
"time"

C "github.com/sagernet/sing/common"
Expand All @@ -16,8 +14,7 @@ import (
"github.com/sagernet/sing/common/random"
"github.com/sagernet/sing/common/rw"
"github.com/sagernet/sing/protocol/shadowsocks"
"github.com/sagernet/sing/protocol/shadowsocks/shadowaead"
"github.com/sagernet/sing/protocol/shadowsocks/shadowaead_2022"
"github.com/sagernet/sing/protocol/shadowsocks/shadowimpl"
"github.com/v2fly/v2ray-core/v5/common"
"github.com/v2fly/v2ray-core/v5/common/buf"
"github.com/v2fly/v2ray-core/v5/common/net"
Expand Down Expand Up @@ -48,57 +45,17 @@ func NewClient(ctx context.Context, config *ClientConfig) (*Outbound, error) {
Network: net.Network_TCP,
},
}
if config.Method == shadowsocks.MethodNone {
o.method = shadowsocks.NewNone()
} else if common.Contains(shadowaead.List, config.Method) {
var key []byte
if config.Key != "" {
bKdy, err := base64.StdEncoding.DecodeString(config.Key)
if err != nil {
return nil, newError("shadowsocks: decode key ", config.Key).Base(err)
}
key = bKdy
}
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)
if err != nil {
return nil, newError("create method").Base(err)
}
o.method = method
} else if common.Contains(shadowaead_2022.List, config.Method) {
if config.Password != "" {
return nil, newError("use psk instead of password")
}
if config.Key == "" {
return nil, newError("missing psk")
}
var pskList [][]byte
for _, ks := range strings.Split(config.Key, ":") {
psk, err := base64.StdEncoding.DecodeString(ks)
if err != nil {
return nil, newError("decode key ", ks).Base(err)
}
pskList = append(pskList, psk)
var rng io.Reader = random.Default
if config.ReducedIvHeadEntropy {
rng = &shadowsocks.ReducedEntropyReader{
Reader: rng,
}
var rng io.Reader = random.Default
if config.ReducedIvHeadEntropy {
rng = &shadowsocks.ReducedEntropyReader{
Reader: rng,
}
}
method, err := shadowaead_2022.New(config.Method, pskList, rng)
if err != nil {
return nil, newError("create method").Base(err)
}
o.method = method
} else {
return nil, newError("unknown method ", config.Method)
}
method, err := shadowimpl.FetchMethod(config.Method, config.Key, config.Password, rng)
if err != nil {
return nil, err
}
o.method = method
return o, nil
}

Expand Down

0 comments on commit d5d6a0c

Please sign in to comment.