@@ -200,17 +200,9 @@ func hy(u *url.URL, i int) (*map[string]interface{}, string, error) {
200200 port , _ = strconv .Atoi (portStr )
201201 }
202202
203- tls := map [string ]interface {}{
204- "enabled" : true ,
205- "server_name" : query .Get ("peer" ),
206- }
207- alpn := query .Get ("alpn" )
208- insecure := query .Get ("insecure" )
209- if len (alpn ) > 0 {
210- tls ["alpn" ] = strings .Split (alpn , "," )
211- }
212- if insecure == "1" || insecure == "true" {
213- tls ["insecure" ] = true
203+ security := query .Get ("security" )
204+ if len (security ) == 0 {
205+ security = "tls"
214206 }
215207
216208 tag := u .Fragment
@@ -224,7 +216,7 @@ func hy(u *url.URL, i int) (*map[string]interface{}, string, error) {
224216 "server_port" : port ,
225217 "obfs" : query .Get ("obfsParam" ),
226218 "auth_str" : query .Get ("auth" ),
227- "tls" : tls ,
219+ "tls" : getTls ( security , & query ) ,
228220 }
229221 down , _ := strconv .Atoi (query .Get ("downmbps" ))
230222 up , _ := strconv .Atoi (query .Get ("upmbps" ))
@@ -253,17 +245,9 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
253245 port , _ = strconv .Atoi (portStr )
254246 }
255247
256- tls := map [string ]interface {}{
257- "enabled" : true ,
258- "server_name" : query .Get ("sni" ),
259- }
260- alpn := query .Get ("alpn" )
261- insecure := query .Get ("insecure" )
262- if len (alpn ) > 0 {
263- tls ["alpn" ] = strings .Split (alpn , "," )
264- }
265- if insecure == "1" || insecure == "true" {
266- tls ["insecure" ] = true
248+ security := query .Get ("security" )
249+ if len (security ) == 0 {
250+ security = "tls"
267251 }
268252
269253 tag := u .Fragment
@@ -276,11 +260,13 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
276260 "server" : host ,
277261 "server_port" : port ,
278262 "password" : u .User .Username (),
279- "tls" : tls ,
263+ "tls" : getTls ( security , & query ) ,
280264 }
281265 down , _ := strconv .Atoi (query .Get ("downmbps" ))
282266 up , _ := strconv .Atoi (query .Get ("upmbps" ))
283267 obfs := query .Get ("obfs" )
268+ mport := query .Get ("mport" )
269+ fastopen := query .Get ("fastopen" )
284270 if down > 0 {
285271 hy2 ["down_mbps" ] = down
286272 }
@@ -293,6 +279,12 @@ func hy2(u *url.URL, i int) (*map[string]interface{}, string, error) {
293279 "password" : query .Get ("obfs-password" ),
294280 }
295281 }
282+ if len (mport ) > 0 {
283+ hy2 ["server_ports" ] = strings .Split (mport , "," )
284+ }
285+ if fastopen == "1" || fastopen == "true" {
286+ hy2 ["fastopen" ] = true
287+ }
296288 return & hy2 , tag , nil
297289}
298290
@@ -304,17 +296,9 @@ func anytls(u *url.URL, i int) (*map[string]interface{}, string, error) {
304296 port , _ = strconv .Atoi (portStr )
305297 }
306298
307- tls := map [string ]interface {}{
308- "enabled" : true ,
309- "server_name" : query .Get ("sni" ),
310- }
311- alpn := query .Get ("alpn" )
312- insecure := query .Get ("insecure" )
313- if len (alpn ) > 0 {
314- tls ["alpn" ] = strings .Split (alpn , "," )
315- }
316- if insecure == "1" || insecure == "true" {
317- tls ["insecure" ] = true
299+ security := query .Get ("security" )
300+ if len (security ) == 0 {
301+ security = "tls"
318302 }
319303
320304 tag := u .Fragment
@@ -327,7 +311,7 @@ func anytls(u *url.URL, i int) (*map[string]interface{}, string, error) {
327311 "server" : host ,
328312 "server_port" : port ,
329313 "password" : u .User .Username (),
330- "tls" : tls ,
314+ "tls" : getTls ( security , & query ) ,
331315 }
332316 return & anytls , tag , nil
333317}
@@ -340,21 +324,9 @@ func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
340324 port , _ = strconv .Atoi (portStr )
341325 }
342326
343- tls := map [string ]interface {}{
344- "enabled" : true ,
345- "server_name" : query .Get ("sni" ),
346- }
347- alpn := query .Get ("alpn" )
348- insecure := query .Get ("allow_insecure" )
349- disable_sni := query .Get ("disable_sni" )
350- if len (alpn ) > 0 {
351- tls ["alpn" ] = strings .Split (alpn , "," )
352- }
353- if insecure == "1" || insecure == "true" {
354- tls ["insecure" ] = true
355- }
356- if disable_sni == "1" || disable_sni == "true" {
357- tls ["disable_sni" ] = true
327+ security := query .Get ("security" )
328+ if len (security ) == 0 {
329+ security = "tls"
358330 }
359331
360332 tag := u .Fragment
@@ -371,7 +343,7 @@ func tuic(u *url.URL, i int) (*map[string]interface{}, string, error) {
371343 "password" : password ,
372344 "congestion_control" : query .Get ("congestion_control" ),
373345 "udp_relay_mode" : query .Get ("udp_relay_mode" ),
374- "tls" : tls ,
346+ "tls" : getTls ( security , & query ) ,
375347 }
376348 return & tuic , tag , nil
377349}
@@ -480,9 +452,11 @@ func getTls(security string, q *url.Values) map[string]interface{} {
480452 tls := map [string ]interface {}{}
481453 tls_fp := q .Get ("fp" )
482454 tls_sni := q .Get ("sni" )
483- tls_insecure := q .Get ("allowInsecure" )
455+ tls_allow_insecure := q .Get ("allowInsecure" )
456+ tls_insecure := q .Get ("insecure" )
484457 tls_alpn := q .Get ("alpn" )
485458 tls_ech := q .Get ("ech" )
459+ disable_sni := q .Get ("disable_sni" )
486460 switch security {
487461 case "tls" :
488462 tls ["enabled" ] = true
@@ -500,7 +474,7 @@ func getTls(security string, q *url.Values) map[string]interface{} {
500474 if len (tls_alpn ) > 0 {
501475 tls ["alpn" ] = strings .Split (tls_alpn , "," )
502476 }
503- if tls_insecure == "1" || tls_insecure == "true" {
477+ if tls_insecure == "1" || tls_insecure == "true" || tls_allow_insecure == "1" || tls_allow_insecure == "true" {
504478 tls ["insecure" ] = true
505479 }
506480 if len (tls_fp ) > 0 {
@@ -517,5 +491,8 @@ func getTls(security string, q *url.Values) map[string]interface{} {
517491 },
518492 }
519493 }
494+ if disable_sni == "1" || disable_sni == "true" {
495+ tls ["disable_sni" ] = true
496+ }
520497 return tls
521498}
0 commit comments