@@ -18,6 +18,7 @@ class Surge extends AbstractProtocol
1818 Server::TYPE_VMESS ,
1919 Server::TYPE_TROJAN ,
2020 Server::TYPE_HYSTERIA ,
21+ Server::TYPE_ANYTLS ,
2122 ];
2223 protected $ protocolRequirements = [
2324 'surge.hysteria.protocol_settings.version ' => [2 => '2398 ' ],
@@ -58,6 +59,10 @@ public function handle()
5859 $ proxies .= self ::buildHysteria ($ item ['password ' ], $ item );
5960 $ proxyGroup .= $ item ['name ' ] . ', ' ;
6061 }
62+ if ($ item ['type ' ] === Server::TYPE_ANYTLS ) {
63+ $ proxies .= self ::buildAnyTLS ($ item ['password ' ], $ item );
64+ $ proxyGroup .= $ item ['name ' ] . ', ' ;
65+ }
6166 }
6267
6368
@@ -193,6 +198,28 @@ public static function buildTrojan($password, $server)
193198 return $ uri ;
194199 }
195200
201+ //参考文档: https://manual.nssurge.com/policy/proxy.html
202+ public static function buildAnyTLS ($ password , $ server )
203+ {
204+ $ protocol_settings = data_get ($ server , 'protocol_settings ' , []);
205+ $ config = [
206+ "{$ server ['name ' ]}=anytls " ,
207+ "{$ server ['host ' ]}" ,
208+ "{$ server ['port ' ]}" ,
209+ "password= {$ password }" ,
210+ ];
211+ if ($ serverName = data_get ($ protocol_settings , 'tls.server_name ' )) {
212+ $ config [] = "sni= {$ serverName }" ;
213+ }
214+ if (data_get ($ protocol_settings , 'tls.allow_insecure ' )) {
215+ $ config [] = 'skip-cert-verify=true ' ;
216+ }
217+ $ config = array_filter ($ config );
218+ $ uri = implode (', ' , $ config );
219+ $ uri .= "\r\n" ;
220+ return $ uri ;
221+ }
222+
196223 //参考文档: https://manual.nssurge.com/policy/proxy.html
197224 public static function buildHysteria ($ password , $ server )
198225 {
0 commit comments