@@ -24,6 +24,8 @@ export default function Surfboard_Producer() {
2424 return vmess ( proxy ) ;
2525 case 'http' :
2626 return http ( proxy ) ;
27+ case 'snell' :
28+ return snell ( proxy ) ;
2729 case 'socks5' :
2830 return socks5 ( proxy ) ;
2931 case 'anytls' :
@@ -60,6 +62,41 @@ function anytls(proxy) {
6062
6163 return result . toString ( ) ;
6264}
65+ function snell ( proxy ) {
66+ if ( proxy . version > 3 ) {
67+ throw new Error (
68+ `Platform ${ targetPlatform } does not support snell version ${ proxy . version } ` ,
69+ ) ;
70+ }
71+ const result = new Result ( proxy ) ;
72+ result . append ( `${ proxy . name } =${ proxy . type } ,${ proxy . server } ,${ proxy . port } ` ) ;
73+ result . appendIfPresent ( `,version=${ proxy . version } ` , 'version' ) ;
74+ result . appendIfPresent ( `,psk=${ proxy . psk } ` , 'psk' ) ;
75+
76+ // obfs
77+ result . appendIfPresent (
78+ `,obfs=${ proxy [ 'obfs-opts' ] ?. mode } ` ,
79+ 'obfs-opts.mode' ,
80+ ) ;
81+ result . appendIfPresent (
82+ `,obfs-host=${ proxy [ 'obfs-opts' ] ?. host } ` ,
83+ 'obfs-opts.host' ,
84+ ) ;
85+ result . appendIfPresent (
86+ `,obfs-uri=${ proxy [ 'obfs-opts' ] ?. path } ` ,
87+ 'obfs-opts.path' ,
88+ ) ;
89+
90+ // tfo
91+ result . appendIfPresent ( `,tfo=${ proxy . tfo } ` , 'tfo' ) ;
92+
93+ // udp
94+ if ( proxy . version >= 3 ) {
95+ result . appendIfPresent ( `,udp-relay=${ proxy . udp } ` , 'udp' ) ;
96+ }
97+
98+ return result . toString ( ) ;
99+ }
63100function shadowsocks ( proxy ) {
64101 const result = new Result ( proxy ) ;
65102 result . append ( `${ proxy . name } =${ proxy . type } ,${ proxy . server } ,${ proxy . port } ` ) ;
0 commit comments