整理注释、文档、代码

This commit is contained in:
e1732a364fed
2000-01-01 00:00:00 +00:00
parent 52e829fa00
commit 89c50fe4df
6 changed files with 24 additions and 40 deletions

View File

@@ -10,7 +10,9 @@ host = "0.0.0.0"
port = 4433
#version = 0 # 在服务端如果version给出则只 支持 监听特定版本的vless, 若请求版本不符合,将拒绝连接(或者回落).
insecure = true
fallback = ":80" # 默认回落地址.ip必须是本机ip(可以省略ip而只写端口,程序会默认补全127.0.0.1), 或者unix domain socket的文件名/路径, 或者 udp://127.0.0.1:80 这种url格式。
fallback = ":80"
# 默认回落地址.ip必须是本机ip(可以省略ip而只写端口,程序会默认补全127.0.0.1),
# 或者unix domain socket的文件名/路径, 或者 udp://127.0.0.1:80 这种url格式。
# 用udp以试图回落到 nginx的 无tls 的 udp的 http3 服务端口,适用于 quic的情况. 只能由其它协议回落到quic, 而不能由 quic 回落到quic, 没办法, 依赖的代码包不够强大.
@@ -19,7 +21,11 @@ key = "cert.key" # 如果 cert和key中 有一项没给出, 或者文件不
# 我们作为示例, 就直接随机证书了, 不提供现成的证书。这样可以 避免很多小白 共同使用相同的证书 导致被 审查者 察觉.
#xver = 1 # 可选, 高级用法, 小白不用管. 若为1或者2, 则监听 PROXY protocol, 用于nginx等回落到 verysimple. 实际上目前无论给出的是1还是2, 都会同时监听 v1和v2. 不过这只是目前代码的实现而已, 也许未来会改动, 所以你还是确定选用一个版本.
#xver = 1
# 可选, 高级用法, 小白不用管. 若为1或者2, 则监听 PROXY protocol, 用于nginx等回落到 verysimple
# 注意这和fallback项中的 xver意义正好相反.
# 实际上目前无论给出的是1还是2, 都会同时监听 v1和v2. 不过这只是目前代码的实现而已, 也许未来会改动, 所以你还是确定选用一个版本.
# ca = "ca.crt" # 可选, 用于验证客户端证书
@@ -27,7 +33,7 @@ key = "cert.key" # 如果 cert和key中 有一项没给出, 或者文件不
# extra = { tls_minVersion = "1.2" } # 默认的 minVersion 是1.3你还可以设成1.2,其它值无效。
# fullcone = true # 只有当listen和dial 均为 fullcone时, 才会开启fullcone
# fullcone = true # 只有当listen和dial在 client和server配置 均为 fullcone时, 才会真正fullcone生效
[[dial]]
protocol = "direct"
@@ -57,7 +63,10 @@ dest = 6060 # 必填, 这里的意思是 回落到本机端口 6060, 格式
# 另外sni和alpn的 匹配 只在 我们listen配置使用了 tls时才会有效比如如果nginx前置的话那么我们就是无法匹配这两项的.
#xver = 1 # 可选如果为1则表示 使用 PROXY protocol version 1, 如果为 2, 则表示 PROXY protocol version 2, 其他值无效。
#xver = 1
# 可选, 用于 回落到nginx 等情况时 传递客户端原始地址。
# 如果为1则表示 使用 PROXY protocol version 1, 如果为 2, 则表示 PROXY protocol version 2, 其他值无效。
[[fallback]]
dest = 80

2
go.mod
View File

@@ -30,7 +30,6 @@ require (
)
require (
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da // indirect
github.com/andybalholm/brotli v1.0.4 // indirect
github.com/klauspost/compress v1.15.9 // indirect
github.com/riobard/go-bloom v0.0.0-20200614022211-cdc8013cb5b3 // indirect
@@ -50,7 +49,6 @@ require (
github.com/nxadm/tail v1.4.8 // indirect
github.com/onsi/ginkgo v1.16.5 // indirect
github.com/shadowsocks/go-shadowsocks2 v0.1.5
github.com/shadowsocks/shadowsocks-go v0.0.0-20200409064450-3e585ff90601
go.uber.org/multierr v1.8.0 // indirect
golang.org/x/mod v0.6.0-dev.0.20220106191415-9b9b3d81d5e3 // indirect
golang.org/x/text v0.3.7 // indirect

4
go.sum
View File

@@ -10,8 +10,6 @@ git.apache.org/thrift.git v0.0.0-20180902110319-2566ecd5d999/go.mod h1:fPE2ZNJGy
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/toml v1.2.1 h1:9F2/+DoOYIOksmaJFPw1tGFy1eDnIJXg+UHjuD8lTak=
github.com/BurntSushi/toml v1.2.1/go.mod h1:CxXYINrC8qIiEnFrOxCa7Jy5BFHlXnUU2pbicEuybxQ=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da h1:KjTM2ks9d14ZYCvmHS9iAKVt9AyzRSqNU1qabPih5BY=
github.com/aead/chacha20 v0.0.0-20180709150244-8b13a72661da/go.mod h1:eHEWzANqSiWQsof+nXEI9bUVUyV6F53Fp89EuCh2EAA=
github.com/andybalholm/brotli v1.0.4 h1:V7DdXeJtZscaqfNuAdSRuRFzuiKlHSC/Zh3zl9qY3JY=
github.com/andybalholm/brotli v1.0.4/go.mod h1:fO7iG3H7G2nSZ7m0zPUDn85XEX2GTukHGRSepvi9Eig=
github.com/anmitsu/go-shlex v0.0.0-20161002113705-648efa622239/go.mod h1:2FmKhYUyUczH0OGQWaF5ceTx0UBShxjsH6f8oGKYe2c=
@@ -189,8 +187,6 @@ github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/shadowsocks/go-shadowsocks2 v0.1.5 h1:PDSQv9y2S85Fl7VBeOMF9StzeXZyK1HakRm86CUbr28=
github.com/shadowsocks/go-shadowsocks2 v0.1.5/go.mod h1:AGGpIoek4HRno4xzyFiAtLHkOpcoznZEkAccaI/rplM=
github.com/shadowsocks/shadowsocks-go v0.0.0-20200409064450-3e585ff90601 h1:XU9hik0exChEmY92ALW4l9WnDodxLVS9yOSNh2SizaQ=
github.com/shadowsocks/shadowsocks-go v0.0.0-20200409064450-3e585ff90601/go.mod h1:mttDPaeLm87u74HMrP+n2tugXvIKWcwff/cqSX0lehY=
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/github_flavored_markdown v0.0.0-20181002035957-2122de532470/go.mod h1:2dOwnU2uBioM+SGy2aZoq1f/Sd1l9OkAeAUvjSyvgU0=

View File

@@ -672,7 +672,7 @@ func passToOutClient(iics incomingInserverConnState, isfallback bool, wlc net.Co
////////////////////////////// 读取 First Payload 阶段 /////////////////////////////////////
//因为无论是 sniffing还是后面 proxy的握手还是 lazy功能抑或是 ws的 earlydata都要预先获得用户数据所以要提前读一下
//因为无论是 sniffing还是后面 proxy的握手抑或是 ws的 earlydata都要预先获得用户数据所以要提前读一下
//serverEnd 的 lazy 比较特殊,要自己读

View File

@@ -39,7 +39,7 @@ type BaseInterface interface {
/////////////////// 传输层 ///////////////////
MultiTransportLayer() bool
MultiTransportLayer() bool //同时使用多个传输层来传输数据。direct, socks5 和 shadowsocks 都为true
Network() string //传输层协议,如 tcp, udp, unix, kcp, etc. 这里叫做Network而不是transport, 是遵循 golang 标准包 net包的用法。我们兼容 net的Listen等方法, 可把Network直接作为 net.Listen等方法的 network 参数。
GetXver() int

View File

@@ -26,7 +26,7 @@ ss不像vmess等协议一样只使用一种传输层协议来传输 tcp和udp
另外本包是普通的ss AEAD Ciphers ,不过似乎它还是有问题。所以还要以后研究ss-2022
另外本包是普通的ss AEAD Ciphers ,不过它还是有问题。所以以后研究ss-2022
https://github.com/shadowsocks/shadowsocks-org/issues/183
@@ -45,7 +45,6 @@ import (
"github.com/e1732a364fed/v2ray_simple/netLayer"
"github.com/e1732a364fed/v2ray_simple/utils"
"github.com/shadowsocks/go-shadowsocks2/core"
ss "github.com/shadowsocks/shadowsocks-go/shadowsocks"
"go.uber.org/zap"
)
@@ -56,19 +55,6 @@ const (
ATypIP6 = 0x4
)
//implements core.Cipher
type shadowCipher struct {
cipher *ss.Cipher
}
func (c *shadowCipher) StreamConn(conn net.Conn) net.Conn {
return ss.NewConn(conn, c.cipher.Copy())
}
func (c *shadowCipher) PacketConn(conn net.PacketConn) net.PacketConn {
return ss.NewSecurePacketConn(conn, c.cipher.Copy())
}
func initShadowCipher(info MethodPass) (cipher core.Cipher) {
var method, password = info.Method, info.Password
//根据 https://github.com/shadowsocks/shadowsocks-org/wiki/SIP002-URI-Scheme
@@ -77,21 +63,16 @@ func initShadowCipher(info MethodPass) (cipher core.Cipher) {
return
}
cp, _ := ss.NewCipher(method, password)
if cp != nil {
cipher = &shadowCipher{cipher: cp}
}
if cipher == nil {
var err error
cipher, err = core.PickCipher(strings.ToUpper(method), nil, password)
if err != nil {
if ce := utils.CanLogErr("ss initShadowCipher err"); ce != nil {
ce.Write(zap.Error(err))
}
return
var err error
cipher, err = core.PickCipher(strings.ToUpper(method), nil, password)
if err != nil {
if ce := utils.CanLogErr("ss initShadowCipher err"); ce != nil {
ce.Write(zap.Error(err))
}
return
}
return
}