@@ -67,6 +67,18 @@ function getQxHttpObfs(proxy) {
6767 : 'http' ;
6868}
6969
70+ function appendTlsVerification ( result , proxy ) {
71+ const attr = isPresent ( proxy , 'name-cert-verify' )
72+ ? 'name-cert-verify'
73+ : 'skip-cert-verify' ;
74+ result . appendIfPresent (
75+ `,tls-verification=${
76+ proxy [ 'name-cert-verify' ] ?? ! proxy [ 'skip-cert-verify' ]
77+ } `,
78+ attr ,
79+ ) ;
80+ }
81+
7082function shadowsocks ( proxy ) {
7183 const result = new Result ( proxy ) ;
7284 const append = result . append . bind ( result ) ;
@@ -170,10 +182,7 @@ function shadowsocks(proxy) {
170182 ) ;
171183
172184 // tls verification
173- appendIfPresent (
174- `,tls-verification=${ ! proxy [ 'skip-cert-verify' ] } ` ,
175- 'skip-cert-verify' ,
176- ) ;
185+ appendTlsVerification ( result , proxy ) ;
177186 if ( ! isSSOverTls ) {
178187 appendIfPresent ( `,tls-host=${ proxy . sni } ` , 'sni' ) ;
179188 }
@@ -301,10 +310,7 @@ function trojan(proxy) {
301310 ) ;
302311
303312 // tls verification
304- appendIfPresent (
305- `,tls-verification=${ ! proxy [ 'skip-cert-verify' ] } ` ,
306- 'skip-cert-verify' ,
307- ) ;
313+ appendTlsVerification ( result , proxy ) ;
308314 appendIfPresent ( `,tls-host=${ proxy . sni } ` , 'sni' ) ;
309315 }
310316
@@ -395,10 +401,7 @@ function vmess(proxy) {
395401 ) ;
396402
397403 // tls verification
398- appendIfPresent (
399- `,tls-verification=${ ! proxy [ 'skip-cert-verify' ] } ` ,
400- 'skip-cert-verify' ,
401- ) ;
404+ appendTlsVerification ( result , proxy ) ;
402405 appendIfPresent ( `,tls-host=${ proxy . sni } ` , 'sni' ) ;
403406 }
404407
@@ -501,10 +504,7 @@ function vless(proxy) {
501504 ) ;
502505
503506 // tls verification
504- appendIfPresent (
505- `,tls-verification=${ ! proxy [ 'skip-cert-verify' ] } ` ,
506- 'skip-cert-verify' ,
507- ) ;
507+ appendTlsVerification ( result , proxy ) ;
508508 appendIfPresent ( `,tls-host=${ proxy . sni } ` , 'sni' ) ;
509509 }
510510
@@ -563,10 +563,7 @@ function anytls(proxy) {
563563 `,tls-cert-sha256=${ proxy [ 'tls-fingerprint' ] } ` ,
564564 'tls-fingerprint' ,
565565 ) ;
566- appendIfPresent (
567- `,tls-verification=${ ! proxy [ 'skip-cert-verify' ] } ` ,
568- 'skip-cert-verify' ,
569- ) ;
566+ appendTlsVerification ( result , proxy ) ;
570567 appendIfPresent ( `,tls-host=${ proxy . sni } ` , 'sni' ) ;
571568
572569 appendIfPresent ( `,fast-open=${ proxy . tfo } ` , 'tfo' ) ;
@@ -618,10 +615,7 @@ function http(proxy) {
618615 ) ;
619616
620617 // tls verification
621- appendIfPresent (
622- `,tls-verification=${ ! proxy [ 'skip-cert-verify' ] } ` ,
623- 'skip-cert-verify' ,
624- ) ;
618+ appendTlsVerification ( result , proxy ) ;
625619 appendIfPresent ( `,tls-host=${ proxy . sni } ` , 'sni' ) ;
626620 }
627621
@@ -679,10 +673,7 @@ function socks5(proxy) {
679673 ) ;
680674
681675 // tls verification
682- appendIfPresent (
683- `,tls-verification=${ ! proxy [ 'skip-cert-verify' ] } ` ,
684- 'skip-cert-verify' ,
685- ) ;
676+ appendTlsVerification ( result , proxy ) ;
686677 appendIfPresent ( `,tls-host=${ proxy . sni } ` , 'sni' ) ;
687678 }
688679
0 commit comments