@@ -1557,7 +1557,7 @@ describe('Proxy structured producers', function () {
15571557 } ) ;
15581558 } ) ;
15591559
1560- it ( 'preserves numeric v2ray-plugin mux values across Clash-family YAML producers' , function ( ) {
1560+ it ( 'preserves numeric v2ray-plugin mux values across non-Mihomo Clash-family YAML producers' , function ( ) {
15611561 const buildProxy = ( name , mux ) => ( {
15621562 type : 'ss' ,
15631563 name,
@@ -1577,12 +1577,7 @@ describe('Proxy structured producers', function () {
15771577 } ,
15781578 } ) ;
15791579
1580- for ( const platform of [
1581- 'Clash' ,
1582- 'ClashMeta' ,
1583- 'Shadowrocket' ,
1584- 'Stash' ,
1585- ] ) {
1580+ for ( const platform of [ 'Clash' , 'Shadowrocket' , 'Stash' ] ) {
15861581 const internal = produceInternal ( platform , [
15871582 buildProxy ( `${ platform } Mux On` , 1 ) ,
15881583 buildProxy ( `${ platform } Mux Off` , 0 ) ,
@@ -1608,6 +1603,109 @@ describe('Proxy structured producers', function () {
16081603 }
16091604 } ) ;
16101605
1606+ it ( 'normalizes plugin mux values to booleans for Mihomo-compatible YAML producers' , function ( ) {
1607+ const buildProxy = ( name , mux ) => ( {
1608+ type : 'ss' ,
1609+ name,
1610+ server : 'ss.example.com' ,
1611+ port : 8388 ,
1612+ cipher : 'aes-128-gcm' ,
1613+ password : 'secret' ,
1614+ plugin : 'v2ray-plugin' ,
1615+ 'plugin-opts' : {
1616+ mode : 'websocket' ,
1617+ host : 'cdn.example.com' ,
1618+ path : '/socket' ,
1619+ tls : true ,
1620+ mux,
1621+ } ,
1622+ } ) ;
1623+ const cases = [
1624+ [ 'Number On' , 1 , true ] ,
1625+ [ 'Number Off' , 0 , false ] ,
1626+ [ 'Boolean On' , true , true ] ,
1627+ [ 'Boolean Off' , false , false ] ,
1628+ [ 'String True' , ' TRUE ' , true ] ,
1629+ [ 'String False' , ' false ' , false ] ,
1630+ [ 'String One' , '1' , true ] ,
1631+ [ 'String Zero' , '0' , false ] ,
1632+ ] ;
1633+ const proxies = cases . map ( ( [ name , mux ] ) =>
1634+ buildProxy ( `Mihomo ${ name } ` , mux ) ,
1635+ ) ;
1636+
1637+ for ( const platform of [ 'Mihomo' , 'ClashMeta' ] ) {
1638+ const internal = produceInternal ( platform , proxies ) ;
1639+ const external = loadProducedYaml ( platform , proxies ) ;
1640+
1641+ expect ( internal , platform ) . to . have . length ( cases . length ) ;
1642+ expect ( external . proxies , platform ) . to . have . length ( cases . length ) ;
1643+
1644+ cases . forEach ( ( [ name , , expected ] , index ) => {
1645+ expect (
1646+ internal [ index ] [ 'plugin-opts' ] . mux ,
1647+ `${ platform } internal ${ name } ` ,
1648+ ) . to . equal ( expected ) ;
1649+ expect (
1650+ external . proxies [ index ] [ 'plugin-opts' ] . mux ,
1651+ `${ platform } external ${ name } ` ,
1652+ ) . to . equal ( expected ) ;
1653+ } ) ;
1654+ }
1655+ } ) ;
1656+
1657+ it ( 'preserves Mihomo shadowsocks gost-plugin options with boolean mux' , function ( ) {
1658+ const proxy = {
1659+ type : 'ss' ,
1660+ name : 'Mihomo Gost Plugin' ,
1661+ server : 'ss.example.com' ,
1662+ port : 8388 ,
1663+ cipher : 'aes-128-gcm' ,
1664+ password : 'secret' ,
1665+ plugin : 'gost-plugin' ,
1666+ 'plugin-opts' : {
1667+ mode : 'websocket' ,
1668+ tls : true ,
1669+ fingerprint : 'SHA256:TEST' ,
1670+ certificate : 'inline-test-client-cert' ,
1671+ 'private-key' : 'inline-test-client-key' ,
1672+ 'skip-cert-verify' : true ,
1673+ host : 'cdn.example.com' ,
1674+ path : '/socket' ,
1675+ mux : 1 ,
1676+ headers : {
1677+ custom : 'value' ,
1678+ } ,
1679+ } ,
1680+ } ;
1681+
1682+ const internal = produceInternal ( 'Mihomo' , proxy ) ;
1683+ const external = loadProducedYaml ( 'Mihomo' , proxy ) ;
1684+ const expected = {
1685+ type : 'ss' ,
1686+ name : 'Mihomo Gost Plugin' ,
1687+ plugin : 'gost-plugin' ,
1688+ 'plugin-opts' : {
1689+ mode : 'websocket' ,
1690+ tls : true ,
1691+ fingerprint : 'SHA256:TEST' ,
1692+ certificate : 'inline-test-client-cert' ,
1693+ 'private-key' : 'inline-test-client-key' ,
1694+ 'skip-cert-verify' : true ,
1695+ host : 'cdn.example.com' ,
1696+ path : '/socket' ,
1697+ mux : true ,
1698+ headers : {
1699+ custom : 'value' ,
1700+ } ,
1701+ } ,
1702+ } ;
1703+
1704+ expect ( internal ) . to . have . length ( 1 ) ;
1705+ expectSubset ( internal [ 0 ] , expected ) ;
1706+ expectSubset ( external . proxies [ 0 ] , expected ) ;
1707+ } ) ;
1708+
16111709 it ( 'keeps legacy single-line proxy output by default for Clash-style YAML producers' , function ( ) {
16121710 const proxy = {
16131711 type : 'ss' ,
0 commit comments