mirror of
				https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
				synced 2025-10-31 13:41:07 +08:00 
			
		
		
		
	fix: 域名解析修复; 结果增加 _IP4P 字段
This commit is contained in:
		
							parent
							
								
									fea9de4fae
								
							
						
					
					
						commit
						a0c1bbbf70
					
				| @ -1,6 +1,6 @@ | ||||
| { | ||||
|   "name": "sub-store", | ||||
|   "version": "2.14.349", | ||||
|   "version": "2.14.350", | ||||
|   "description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.", | ||||
|   "main": "src/main.js", | ||||
|   "scripts": { | ||||
|  | ||||
| @ -360,14 +360,10 @@ function ScriptOperator(script, targetPlatform, $arguments, source) { | ||||
|     }; | ||||
| } | ||||
| 
 | ||||
| function parseIP4P(ip) { | ||||
| function parseIP4P(IP4P) { | ||||
|     let server; | ||||
|     let port; | ||||
|     try { | ||||
|         const IP4P = new ipAddress.Address6(ip).correctForm(); | ||||
|         if (!/^2001::[^:]+:[^:]+:[^:]+$/.test(IP4P)) { | ||||
|             throw new Error(`Invalid IP4P: ${IP4P}`); | ||||
|         } | ||||
|         let array = IP4P.split(':'); | ||||
| 
 | ||||
|         port = parseInt(array[2], 16); | ||||
| @ -623,7 +619,7 @@ function ResolveDomainOperator({ | ||||
|                 if (!p['_no-resolve']) { | ||||
|                     if (results[p.server]) { | ||||
|                         p._resolved_ips = results[p.server]; | ||||
|                         const ip = Array.isArray(results[p.server]) | ||||
|                         let ip = Array.isArray(results[p.server]) | ||||
|                             ? results[p.server][ | ||||
|                                   Math.floor( | ||||
|                                       Math.random() * results[p.server].length, | ||||
| @ -631,18 +627,30 @@ function ResolveDomainOperator({ | ||||
|                               ] | ||||
|                             : results[p.server]; | ||||
|                         if (type === 'IPv6' && isIPv6(ip)) { | ||||
|                             const { server, port } = parseIP4P(ip); | ||||
|                             if (server && port) { | ||||
|                             ip = new ipAddress.Address6(ip).correctForm(); | ||||
|                             if (/^2001::[^:]+:[^:]+:[^:]+$/.test(ip)) { | ||||
|                                 const { server, port } = parseIP4P(ip); | ||||
|                                 if (server && port) { | ||||
|                                     p._domain = p.server; | ||||
|                                     p.server = server; | ||||
|                                     p.port = port; | ||||
|                                     p.resolved = true; | ||||
|                                     p._IPv4 = p.server; | ||||
|                                     p._IP4P = ip; | ||||
|                                     if (!isIP(p._IP)) { | ||||
|                                         p._IP = p.server; | ||||
|                                     } | ||||
|                                 } else if (!p.resolved) { | ||||
|                                     p.resolved = false; | ||||
|                                 } | ||||
|                             } else { | ||||
|                                 p._domain = p.server; | ||||
|                                 p.server = server; | ||||
|                                 p.port = port; | ||||
|                                 p.server = ip; | ||||
|                                 p.resolved = true; | ||||
|                                 p._IPv4 = p.server; | ||||
|                                 p[`_${type}`] = p.server; | ||||
|                                 if (!isIP(p._IP)) { | ||||
|                                     p._IP = p.server; | ||||
|                                 } | ||||
|                             } else { | ||||
|                                 p.resolved = false; | ||||
|                             } | ||||
|                         } else { | ||||
|                             p._domain = p.server; | ||||
| @ -653,7 +661,7 @@ function ResolveDomainOperator({ | ||||
|                                 p._IP = p.server; | ||||
|                             } | ||||
|                         } | ||||
|                     } else { | ||||
|                     } else if (!p.resolved) { | ||||
|                         p.resolved = false; | ||||
|                     } | ||||
|                 } | ||||
|  | ||||
| @ -8,7 +8,7 @@ function operator(proxies = [], targetPlatform, context) { | ||||
|   // 0. 结构大致参考了 Clash.Meta(mihomo), 可参考 mihomo 的文档, 例如 `xudp`, `smux` 都可以自己设置. 但是有私货, 下面是我能想起来的一些私货
 | ||||
|   // 1. `_no-resolve` 为不解析域名
 | ||||
|   // 2. 域名解析后 会多一个 `_resolved` 字段, 表示是否解析成功
 | ||||
|   // 3. 域名解析后会有`_IPv4`, `_IPv6`, `_IP`(若有多个步骤, 只取第一次成功的 v4 或 v6 数据), `_domain` 字段, `_resolved_ips` 为解析出的所有 IP
 | ||||
|   // 3. 域名解析后会有`_IPv4`, `_IPv6`, `_IP`(若有多个步骤, 只取第一次成功的 v4 或 v6 数据), `_IP4P`(若解析类型为 IPv6 且符合 IP4P 类型, 将自动转换), `_domain` 字段, `_resolved_ips` 为解析出的所有 IP
 | ||||
|   // 4. 节点字段 `exec` 为 `ssr-local` 路径, 默认 `/usr/local/bin/ssr-local`; 端口从 10000 开始递增(暂不支持配置)
 | ||||
|   // 5. `_subName` 为单条订阅名
 | ||||
|   // 6. `_collectionName` 为组合订阅名
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 xream
						xream