@@ -218,13 +218,13 @@ function convertProxy(p: Proxy): SingboxOutbound | null {
218218 }
219219}
220220
221- const COUNTRY_GROUPS : Array < { tag : string ; prefix : string ; re : RegExp } > = [
222- { tag : '🇭🇰 香港' , prefix : 'HK' , re : / H K _ \d + / } ,
223- { tag : '🇯🇵 日本' , prefix : 'JP' , re : / J P _ \d + / } ,
224- { tag : '🇺🇸 美国' , prefix : 'US' , re : / U S _ \d + / } ,
225- { tag : '🇨🇳 台湾' , prefix : 'TW' , re : / T W _ \d + / } ,
226- { tag : '🇸🇬 新加坡' , prefix : 'SG' , re : / S G _ \d + / } ,
227- { tag : '🇰🇷 韩国' , prefix : 'KR' , re : / K R _ \d + / } ,
221+ const COUNTRY_GROUPS : Array < { tag : string ; re : RegExp } > = [
222+ { tag : '🇭🇰 香港' , re : / H K _ \d + / } ,
223+ { tag : '🇯🇵 日本' , re : / J P _ \d + / } ,
224+ { tag : '🇺🇸 美国' , re : / U S _ \d + / } ,
225+ { tag : '🇨🇳 台湾' , re : / T W _ \d + / } ,
226+ { tag : '🇸🇬 新加坡' , re : / S G _ \d + / } ,
227+ { tag : '🇰🇷 韩国' , re : / K R _ \d + / } ,
228228] ;
229229
230230function mihomoToSingbox ( proxies : Proxy [ ] ) : Record < string , unknown > {
@@ -333,15 +333,28 @@ function mihomoToSingbox(proxies: Proxy[]): Record<string, unknown> {
333333 } ;
334334}
335335
336+ function fixAiName ( s : string ) : string {
337+ return s . replace ( '💬 Ai平台' , '💬 AI平台' ) . replace ( '💬 OpenAi' , '💬 AI平台' ) ;
338+ }
339+
340+ function fixAiGroupName ( groups : Record < string , unknown > [ ] ) : Record < string , unknown > [ ] {
341+ return groups . map ( g => ( { ...g , name : fixAiName ( String ( g . name ) ) } ) ) ;
342+ }
343+
344+ function fixAiRules ( rules : string [ ] ) : string [ ] {
345+ return rules . map ( fixAiName ) ;
346+ }
347+
336348// --- main ---
337349
338350function main ( ) {
339351 const acl4ssrProxies = readYaml < { proxies : Proxy [ ] } > ( path . join ( DATA_DIR , 'acl4ssr-raw.yaml' ) ) . proxies ;
340352 const freesubProxies = readYaml < { proxies : Proxy [ ] } > ( path . join ( DATA_DIR , 'freesub-raw.yaml' ) ) . proxies ;
341- const curatedProxies = readYaml < { proxies : Proxy [ ] } > ( path . join ( DATA_DIR , 'curated-raw.yaml' ) ) . proxies ;
353+ const best1Proxies = readYaml < { proxies : Proxy [ ] } > ( path . join ( DATA_DIR , 'best1-raw.yaml' ) ) . proxies ;
354+ const best2Proxies = readYaml < { proxies : Proxy [ ] } > ( path . join ( DATA_DIR , 'best2-raw.yaml' ) ) . proxies ;
342355 const allProxies = readYaml < { proxies : Proxy [ ] } > ( path . join ( DATA_DIR , 'all-raw.yaml' ) ) . proxies ;
343356
344- console . log ( `ACL4SSR: ${ acl4ssrProxies . length } , freeSub: ${ freesubProxies . length } , 精选 : ${ curatedProxies . length } , 全部: ${ allProxies . length } ` ) ;
357+ console . log ( `ACL4SSR: ${ acl4ssrProxies . length } , freeSub: ${ freesubProxies . length } , best1 : ${ best1Proxies . length } , best2: ${ best2Proxies . length } , 全部: ${ allProxies . length } ` ) ;
345358
346359 fs . mkdirSync ( OUTPUT_DIR , { recursive : true } ) ;
347360
@@ -386,36 +399,60 @@ function main() {
386399 console . log ( `已写入 output/freesub-nodes.yaml` ) ;
387400 }
388401
389- // curated full config (uses acl4ssr template)
390- if ( acl4ssrTemplate && curatedProxies . length > 0 ) {
391- writeYaml ( path . join ( OUTPUT_DIR , 'curated.yaml' ) , {
392- proxies : curatedProxies ,
393- 'proxy-groups' : acl4ssrTemplate [ 'proxy-groups' ] ,
394- rules : acl4ssrTemplate . rules ,
395- 'rule-providers' : acl4ssrTemplate [ 'rule-providers' ] ,
396- dns : acl4ssrTemplate . dns ,
397- } ) ;
398- console . log ( `已写入 output/curated.yaml (${ curatedProxies . length } 节点)` ) ;
399- }
402+ // best1/best2 outputs (both use acl4ssr template with OpenAi→AI平台 fix)
403+ const fixedGroups = acl4ssrTemplate ? fixAiGroupName ( acl4ssrTemplate [ 'proxy-groups' ] as Record < string , unknown > [ ] ) : null ;
404+ const fixedRules = acl4ssrTemplate ? fixAiRules ( acl4ssrTemplate . rules as string [ ] ) : null ;
405+
406+ const bestBase = {
407+ 'mixed-port' : 7890 ,
408+ 'allow-lan' : false ,
409+ mode : 'rule' ,
410+ 'log-level' : 'warning' ,
411+ 'unified-delay' : true ,
412+ 'tcp-concurrent' : true ,
413+ profile : { 'store-selected' : true } ,
414+ dns : {
415+ enable : true ,
416+ 'enhanced-mode' : 'fake-ip' ,
417+ 'fake-ip-range' : '198.18.0.1/16' ,
418+ 'fake-ip-filter' : [ '*.lan' , '*.local' , '+.msftconnecttest.com' , '+.msftncsi.com' , 'localhost.ptlogin2.qq.com' ] ,
419+ 'default-nameserver' : [ '223.5.5.5' , '119.29.29.29' ] ,
420+ nameserver : [ 'https://dns.alidns.com/dns-query' , 'https://doh.pub/dns-query' ] ,
421+ } ,
422+ } ;
400423
401- // curated nodes only
402- if ( curatedProxies . length > 0 ) {
403- writeYaml ( path . join ( OUTPUT_DIR , 'curated-nodes.yaml' ) , { proxies : curatedProxies } ) ;
404- console . log ( `已写入 output/curated-nodes.yaml` ) ;
405- }
424+ const bestGroups : Array < { label : string ; proxies : Proxy [ ] } > = [
425+ { label : 'best1' , proxies : best1Proxies } ,
426+ { label : 'best2' , proxies : best2Proxies } ,
427+ ] ;
428+
429+ for ( const { label, proxies } of bestGroups ) {
430+ if ( proxies . length === 0 ) continue ;
431+
432+ if ( acl4ssrTemplate && fixedGroups && fixedRules ) {
433+ writeYaml ( path . join ( OUTPUT_DIR , `${ label } .yaml` ) , {
434+ ...bestBase ,
435+ proxies,
436+ 'proxy-groups' : fixedGroups ,
437+ rules : fixedRules ,
438+ 'rule-providers' : acl4ssrTemplate [ 'rule-providers' ] ,
439+ } ) ;
440+ console . log ( `已写入 output/${ label } .yaml (${ proxies . length } 节点)` ) ;
441+ }
442+
443+ writeYaml ( path . join ( OUTPUT_DIR , `${ label } -nodes.yaml` ) , { proxies } ) ;
444+ console . log ( `已写入 output/${ label } -nodes.yaml` ) ;
406445
407- // curated sing-box format
408- if ( curatedProxies . length > 0 ) {
409- const singboxConfig = mihomoToSingbox ( curatedProxies ) ;
446+ const singboxConfig = mihomoToSingbox ( proxies ) ;
410447 fs . writeFileSync (
411- path . join ( OUTPUT_DIR , 'curated -singbox.json' ) ,
448+ path . join ( OUTPUT_DIR , ` ${ label } -singbox.json` ) ,
412449 JSON . stringify ( singboxConfig , null , 2 ) ,
413450 'utf-8' ,
414451 ) ;
415452 const proxyCount = ( singboxConfig . outbounds as unknown [ ] ) . filter (
416453 ( o : unknown ) => ! [ 'selector' , 'urltest' , 'direct' , 'block' , 'dns' ] . includes ( ( o as Record < string , string > ) . type ) ,
417454 ) . length ;
418- console . log ( `已写入 output/curated -singbox.json (${ proxyCount } 节点)` ) ;
455+ console . log ( `已写入 output/${ label } -singbox.json (${ proxyCount } 节点)` ) ;
419456 }
420457
421458 // all nodes
0 commit comments