Просмотр исходного кода

Add MinIdleSession option to AnyTLS outbound

Co-authored-by: anytls <anytls>
anytls 7 месяцев назад
Родитель
Сommit
60b451e6cf

+ 5 - 0
docs/configuration/outbound/anytls.md

@@ -16,6 +16,7 @@ icon: material/new-box
   "password": "8JCsPssfgS8tiRwiMlhARg==",
   "idle_session_check_interval": "30s",
   "idle_session_timeout": "30s",
+  "min_idle_session": 5,
   "tls": {},
 
   ... // Dial Fields
@@ -50,6 +51,10 @@ Interval checking for idle sessions. Default: 30s.
 
 In the check, close sessions that have been idle for longer than this. Default: 30s.
 
+#### min_idle_session
+
+In the check, at least the first `n` idle sessions are kept open. Default value: `n`=0
+
 #### tls
 
 ==Required==

+ 5 - 0
docs/configuration/outbound/anytls.zh.md

@@ -16,6 +16,7 @@ icon: material/new-box
   "password": "8JCsPssfgS8tiRwiMlhARg==",
   "idle_session_check_interval": "30s",
   "idle_session_timeout": "30s",
+  "min_idle_session": 5,
   "tls": {},
 
   ... // 拨号字段
@@ -50,6 +51,10 @@ AnyTLS 密码。
 
 在检查中,关闭闲置时间超过此值的会话。默认值:30秒。
 
+#### min_idle_session
+
+在检查中,至少前 `n` 个空闲会话保持打开状态。默认值:`n`=0
+
 #### tls
 
 ==必填==

+ 1 - 1
go.mod

@@ -3,7 +3,7 @@ module github.com/sagernet/sing-box
 go 1.23.1
 
 require (
-	github.com/anytls/sing-anytls v0.0.2
+	github.com/anytls/sing-anytls v0.0.3
 	github.com/caddyserver/certmagic v0.20.0
 	github.com/cloudflare/circl v1.3.7
 	github.com/cretz/bine v0.2.0

+ 2 - 4
go.sum

@@ -8,10 +8,8 @@ github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa h1:LHTHcTQiSGT7V
 github.com/alexbrainman/sspi v0.0.0-20231016080023-1a75b4708caa/go.mod h1:cEWa1LVoE5KvSD9ONXsZrj0z6KqySlCCNKHlLzbqAt4=
 github.com/andybalholm/brotli v1.1.0 h1:eLKJA0d02Lf0mVpIDgYnqXcUn0GqVmEFny3VuID1U3M=
 github.com/andybalholm/brotli v1.1.0/go.mod h1:sms7XGricyQI9K10gOSf56VKKWS4oLer58Q+mhRPtnY=
-github.com/anytls/sing-anytls v0.0.1 h1:Hex6GFUcgATWMWL2E9YgH/7oPgwdokiIF09UQi5BEC0=
-github.com/anytls/sing-anytls v0.0.1/go.mod h1:7rjN6IukwysmdusYsrV51Fgu1uW6vsrdd6ctjnEAln8=
-github.com/anytls/sing-anytls v0.0.2 h1:25azSh0o/LMcIkhS4ZutgRTIGwh8O3wuOhsThVM9K9o=
-github.com/anytls/sing-anytls v0.0.2/go.mod h1:7rjN6IukwysmdusYsrV51Fgu1uW6vsrdd6ctjnEAln8=
+github.com/anytls/sing-anytls v0.0.3 h1:JAQpETCUiZ1LFAPnO8vyJsdxypvKB4zinXwy9KiqWeQ=
+github.com/anytls/sing-anytls v0.0.3/go.mod h1:7rjN6IukwysmdusYsrV51Fgu1uW6vsrdd6ctjnEAln8=
 github.com/bits-and-blooms/bitset v1.13.0 h1:bAQ9OPNFYbGHV6Nez0tmNI0RiEu7/hxlYJRUA0wFAVE=
 github.com/bits-and-blooms/bitset v1.13.0/go.mod h1:7hO7Gc7Pp1vODcmWvKMRA9BNmbv6a/7QIWpPxHddWR8=
 github.com/caddyserver/certmagic v0.20.0 h1:bTw7LcEZAh9ucYCRXyCpIrSAGplplI0vGYJ4BpCQ/Fc=

+ 1 - 0
option/anytls.go

@@ -21,4 +21,5 @@ type AnyTLSOutboundOptions struct {
 	Password                 string             `json:"password,omitempty"`
 	IdleSessionCheckInterval badoption.Duration `json:"idle_session_check_interval,omitempty"`
 	IdleSessionTimeout       badoption.Duration `json:"idle_session_timeout,omitempty"`
+	MinIdleSession           int                `json:"min_idle_session,omitempty"`
 }

+ 1 - 0
protocol/anytls/outbound.go

@@ -63,6 +63,7 @@ func NewOutbound(ctx context.Context, router adapter.Router, logger log.ContextL
 		Password:                 options.Password,
 		IdleSessionCheckInterval: options.IdleSessionCheckInterval.Build(),
 		IdleSessionTimeout:       options.IdleSessionTimeout.Build(),
+		MinIdleSession:           options.MinIdleSession,
 		DialOut:                  outbound.dialOut,
 		Logger:                   logger,
 	})