@@ -334,14 +334,15 @@ describe('Proxy structured producers', function () {
334334 ) ;
335335 } ) ;
336336
337- it ( 'keeps Snell in sing-box only when include-unsupported-proxy is enabled ' , function ( ) {
337+ it ( 'keeps supported Snell in sing-box by default ' , function ( ) {
338338 const proxy = {
339339 type : 'snell' ,
340340 name : 'sing-box Snell' ,
341341 server : 'snell.example.com' ,
342342 port : 44046 ,
343343 psk : 'secret' ,
344- version : 4 ,
344+ version : 5 ,
345+ _userkey : 'user-secret' ,
345346 udp : false ,
346347 tfo : true ,
347348 'fast-open' : true ,
@@ -359,21 +360,12 @@ describe('Proxy structured producers', function () {
359360 } ,
360361 } ;
361362
362- const { result, errors } = captureErrors ( ( ) =>
363+ const { result : internal , errors } = captureErrors ( ( ) =>
363364 produceInternal ( 'sing-box' , proxy ) ,
364365 ) ;
365- const internal = produceInternal ( 'sing-box' , proxy , {
366- 'include-unsupported-proxy' : true ,
367- } ) ;
368- const external = loadProducedJson ( 'sing-box' , proxy , {
369- 'include-unsupported-proxy' : true ,
370- } ) ;
366+ const external = loadProducedJson ( 'sing-box' , proxy ) ;
371367
372- expect ( result ) . to . deep . equal ( [ ] ) ;
373- expect ( errors ) . to . have . length ( 1 ) ;
374- expect ( errors [ 0 ] ) . to . include (
375- 'Platform sing-box does not support proxy type: snell' ,
376- ) ;
368+ expect ( errors ) . to . deep . equal ( [ ] ) ;
377369 expect ( internal ) . to . have . length ( 1 ) ;
378370 expectSubset ( internal [ 0 ] , {
379371 tag : 'sing-box Snell' ,
@@ -382,6 +374,7 @@ describe('Proxy structured producers', function () {
382374 server_port : 44046 ,
383375 psk : 'secret' ,
384376 version : 4 ,
377+ userkey : 'user-secret' ,
385378 reuse : true ,
386379 network : 'tcp' ,
387380 obfs_mode : 'tls' ,
@@ -399,14 +392,49 @@ describe('Proxy structured producers', function () {
399392 expectSubset ( external . outbounds [ 0 ] , internal [ 0 ] ) ;
400393 } ) ;
401394
402- it ( 'keeps sing-box Snell versions documented by reF1nd and rejects newer versions' , function ( ) {
395+ it ( 'keeps sing-box supported Snell versions by default and maps v5 to v4' , function ( ) {
396+ const proxies = [ 1 , 4 , 5 , 6 , '4x' ] . map ( ( version ) => ( {
397+ type : 'snell' ,
398+ name : `sing-box Snell ${ version } ` ,
399+ server : 'snell.example.com' ,
400+ port : 44046 ,
401+ psk : 'secret' ,
402+ version,
403+ mode : 'unshaped' ,
404+ udp : true ,
405+ reuse : true ,
406+ 'obfs-opts' : {
407+ mode : 'http' ,
408+ host : 'obfs.example.com' ,
409+ } ,
410+ } ) ) ;
411+
412+ const { result, errors } = captureErrors ( ( ) =>
413+ produceInternal ( 'sing-box' , proxies ) ,
414+ ) ;
415+
416+ expect ( result . map ( ( proxy ) => proxy . version ) ) . to . deep . equal ( [ 4 , 4 , 6 ] ) ;
417+ expect ( result [ 1 ] . tag ) . to . equal ( 'sing-box Snell 5' ) ;
418+ expect ( result [ 2 ] . mode ) . to . equal ( 'unshaped' ) ;
419+ expect ( result [ 2 ] ) . to . not . have . property ( 'obfs_mode' ) ;
420+ expect ( errors ) . to . have . length ( 2 ) ;
421+ expect ( errors [ 0 ] ) . to . include (
422+ 'Platform sing-box does not support snell version 1' ,
423+ ) ;
424+ expect ( errors [ 1 ] ) . to . include (
425+ 'Platform sing-box does not support snell version 4x' ,
426+ ) ;
427+ } ) ;
428+
429+ it ( 'keeps legacy Snell versions when include-unsupported-proxy is enabled' , function ( ) {
403430 const proxies = [ 1 , 2 , 3 , 4 , 5 , 6 , '4x' ] . map ( ( version ) => ( {
404431 type : 'snell' ,
405432 name : `sing-box Snell ${ version } ` ,
406433 server : 'snell.example.com' ,
407434 port : 44046 ,
408435 psk : 'secret' ,
409436 version,
437+ _userkey : `user-${ version } ` ,
410438 udp : true ,
411439 reuse : true ,
412440 } ) ) ;
@@ -418,7 +446,7 @@ describe('Proxy structured producers', function () {
418446 ) ;
419447
420448 expect ( result . map ( ( proxy ) => proxy . version ) ) . to . deep . equal ( [
421- 1 , 2 , 3 , 4 , 5 ,
449+ 1 , 2 , 3 , 4 , 5 , 6 ,
422450 ] ) ;
423451 expect (
424452 result . find ( ( proxy ) => proxy . version === 1 ) ,
@@ -429,11 +457,11 @@ describe('Proxy structured producers', function () {
429457 expect ( result . find ( ( proxy ) => proxy . version === 4 ) . reuse ) . to . equal (
430458 true ,
431459 ) ;
432- expect ( errors ) . to . have . length ( 2 ) ;
433- expect ( errors [ 0 ] ) . to . include (
434- 'Platform sing-box does not support snell version 6' ,
460+ expect ( result . find ( ( proxy ) => proxy . version === 5 ) . userkey ) . to . equal (
461+ 'user-5' ,
435462 ) ;
436- expect ( errors [ 1 ] ) . to . include (
463+ expect ( errors ) . to . have . length ( 1 ) ;
464+ expect ( errors [ 0 ] ) . to . include (
437465 'Platform sing-box does not support snell version 4x' ,
438466 ) ;
439467 } ) ;
0 commit comments