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