From 6b9603227b411079e3b9f521ccaec1064967a4f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E7=95=8C?= Date: Tue, 21 Feb 2023 16:34:41 +0800 Subject: [PATCH] Add strict mode support for shadowtls v3 --- go.mod | 2 +- go.sum | 4 ++-- inbound/shadowtls.go | 1 + option/shadowtls.go | 1 + 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index d367ab8e..aab70548 100644 --- a/go.mod +++ b/go.mod @@ -26,7 +26,7 @@ require ( github.com/sagernet/sing v0.1.8-0.20230221060643-3401d210384b github.com/sagernet/sing-dns v0.1.4 github.com/sagernet/sing-shadowsocks v0.1.2-0.20230221080503-769c01d6bba9 - github.com/sagernet/sing-shadowtls v0.0.0-20230221075551-c5ad05179260 + github.com/sagernet/sing-shadowtls v0.0.0-20230221123345-78e50cd7b587 github.com/sagernet/sing-tun v0.1.1 github.com/sagernet/sing-vmess v0.1.2 github.com/sagernet/smux v0.0.0-20220831015742-e0f1988e3195 diff --git a/go.sum b/go.sum index 7ad1e66b..5c3a51f4 100644 --- a/go.sum +++ b/go.sum @@ -133,8 +133,8 @@ github.com/sagernet/sing-dns v0.1.4 h1:7VxgeoSCiiazDSaXXQVcvrTBxFpOePPq/4XdgnUDN github.com/sagernet/sing-dns v0.1.4/go.mod h1:1+6pCa48B1AI78lD+/i/dLgpw4MwfnsSpZo0Ds8wzzk= github.com/sagernet/sing-shadowsocks v0.1.2-0.20230221080503-769c01d6bba9 h1:qS39eA4C7x+zhEkySbASrtmb6ebdy5v0y2M6mgkmSO0= github.com/sagernet/sing-shadowsocks v0.1.2-0.20230221080503-769c01d6bba9/go.mod h1:f3mHTy5shnVM9l8UocMlJgC/1G/zdj5FuEuVXhDinGU= -github.com/sagernet/sing-shadowtls v0.0.0-20230221075551-c5ad05179260 h1:RKeyBMI5kRnno3/WGsW4HrGnZkhISQQrnRxAKXbf5Vg= -github.com/sagernet/sing-shadowtls v0.0.0-20230221075551-c5ad05179260/go.mod h1:Kn1VUIprdkwCgkS6SXYaLmIpKzQbqBIKJBMY+RvBhYc= +github.com/sagernet/sing-shadowtls v0.0.0-20230221123345-78e50cd7b587 h1:OjIXlHT2bblZfp+ciupM4xY9+Ccpj9FsuHRtKRBv+Pg= +github.com/sagernet/sing-shadowtls v0.0.0-20230221123345-78e50cd7b587/go.mod h1:Kn1VUIprdkwCgkS6SXYaLmIpKzQbqBIKJBMY+RvBhYc= github.com/sagernet/sing-tun v0.1.1 h1:2Hg3GAyJWzQ7Ua1j74dE+mI06vaqSBO9yD4tkTjggn4= github.com/sagernet/sing-tun v0.1.1/go.mod h1:WzW/SkT+Nh9uJn/FIYUE2YJHYuPwfbh8sATOzU9QDGw= github.com/sagernet/sing-vmess v0.1.2 h1:RbOZNAId2LrCai8epMoQXlf0XTrou0bfcw08hNBg6lM= diff --git a/inbound/shadowtls.go b/inbound/shadowtls.go index 9b78ed61..21028e05 100644 --- a/inbound/shadowtls.go +++ b/inbound/shadowtls.go @@ -53,6 +53,7 @@ func NewShadowTLS(ctx context.Context, router adapter.Router, logger log.Context Dialer: dialer.New(router, options.Handshake.DialerOptions), }, HandshakeForServerName: handshakeForServerName, + StrictMode: options.StrictMode, Handler: inbound.upstreamContextHandler(), Logger: logger, }) diff --git a/option/shadowtls.go b/option/shadowtls.go index c0911aa0..2b288bd8 100644 --- a/option/shadowtls.go +++ b/option/shadowtls.go @@ -7,6 +7,7 @@ type ShadowTLSInboundOptions struct { Users []ShadowTLSUser `json:"users,omitempty"` Handshake ShadowTLSHandshakeOptions `json:"handshake,omitempty"` HandshakeForServerName map[string]ShadowTLSHandshakeOptions `json:"handshake_for_server_name,omitempty"` + StrictMode bool `json:"strict_mode,omitempty"` } type ShadowTLSUser struct {