@@ -32,45 +32,49 @@ export class Parser extends Convert {
3232
3333 public async parse ( vps : string [ ] = this . vps ) : Promise < void > {
3434 for await ( const v of vps ) {
35- const processVps = this . updateVpsPs ( v ) ;
36-
37- if ( processVps ) {
38- let parser : ParserType | null = null ;
39-
40- if ( processVps . startsWith ( 'vless://' ) && this . hasProtocol ( 'vless' ) ) {
41- parser = new VlessParser ( processVps ) ;
42- } else if ( processVps . startsWith ( 'vmess://' ) && this . hasProtocol ( 'vmess' ) ) {
43- parser = new VmessParser ( processVps ) ;
44- } else if ( processVps . startsWith ( 'trojan://' ) && this . hasProtocol ( 'trojan' ) ) {
45- parser = new TrojanParser ( processVps ) ;
46- } else if ( processVps . startsWith ( 'ss://' ) && this . hasProtocol ( 'shadowsocks' ) ) {
47- parser = new SsParser ( processVps ) ;
48- } else if ( this . isHysteria2 ( processVps ) && this . hasProtocol ( 'hysteria' , 'hysteria2' , 'hy2' ) ) {
49- parser = new Hysteria2Parser ( processVps ) ;
50- }
35+ try {
36+ const processVps = this . updateVpsPs ( v ) ;
37+
38+ if ( processVps ) {
39+ let parser : ParserType | null = null ;
40+
41+ if ( processVps . startsWith ( 'vless://' ) && this . hasProtocol ( 'vless' ) ) {
42+ parser = new VlessParser ( processVps ) ;
43+ } else if ( processVps . startsWith ( 'vmess://' ) && this . hasProtocol ( 'vmess' ) ) {
44+ parser = new VmessParser ( processVps ) ;
45+ } else if ( processVps . startsWith ( 'trojan://' ) && this . hasProtocol ( 'trojan' ) ) {
46+ parser = new TrojanParser ( processVps ) ;
47+ } else if ( processVps . startsWith ( 'ss://' ) && this . hasProtocol ( 'shadowsocks' ) ) {
48+ parser = new SsParser ( processVps ) ;
49+ } else if ( this . isHysteria2 ( processVps ) && this . hasProtocol ( 'hysteria' , 'hysteria2' , 'hy2' ) ) {
50+ parser = new Hysteria2Parser ( processVps ) ;
51+ }
5152
52- if ( parser ) {
53- this . setStore ( processVps , parser ) ;
53+ if ( parser ) {
54+ this . setStore ( processVps , parser ) ;
55+ }
5456 }
55- }
5657
57- if ( v . startsWith ( 'https://' ) || v . startsWith ( 'http://' ) ) {
58- const subContent = await fetchWithRetry ( v , { retries : 3 } ) . then ( r => r . data . text ( ) ) ;
59- const { subType, content } = this . getSubType ( subContent ) ;
58+ if ( v . startsWith ( 'https://' ) || v . startsWith ( 'http://' ) ) {
59+ const subContent = await fetchWithRetry ( v , { retries : 3 } ) . then ( r => r . data . text ( ) ) ;
60+ const { subType, content } = this . getSubType ( subContent ) ;
6061
61- if ( subType === 'base64' && content ) {
62- this . updateExist ( Array . from ( this . originUrls ) ) ;
63- await this . parse ( content . split ( '\n' ) . filter ( Boolean ) ) ;
64- }
65-
66- if ( subType === 'yaml' && content ) {
67- const proxies = content . proxies ;
68- if ( proxies . length ) {
62+ if ( subType === 'base64' && content ) {
6963 this . updateExist ( Array . from ( this . originUrls ) ) ;
70- const vps = getYamlProxies ( proxies ) ;
71- await this . parse ( vps . filter ( Boolean ) ) ;
64+ await this . parse ( content . split ( '\n' ) . filter ( Boolean ) ) ;
65+ }
66+
67+ if ( subType === 'yaml' && content ) {
68+ const proxies = content . proxies ;
69+ if ( proxies . length ) {
70+ this . updateExist ( Array . from ( this . originUrls ) ) ;
71+ const vps = getYamlProxies ( proxies ) ;
72+ await this . parse ( vps . filter ( Boolean ) ) ;
73+ }
7274 }
7375 }
76+ } catch {
77+ continue ;
7478 }
7579 }
7680 }
0 commit comments