mirror of
https://git.mirrors.martin98.com/https://github.com/sub-store-org/Sub-Store.git
synced 2026-05-04 02:08:05 +08:00
feat: IP4P 合并进 IPv6; ProxyUtils 中增加 ipAddress
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sub-store",
|
||||
"version": "2.14.348",
|
||||
"version": "2.14.349",
|
||||
"description": "Advanced Subscription Manager for QX, Loon, Surge, Stash and ShadowRocket.",
|
||||
"main": "src/main.js",
|
||||
"scripts": {
|
||||
@@ -26,6 +26,7 @@
|
||||
"dns-packet": "^5.6.1",
|
||||
"express": "^4.17.1",
|
||||
"http-proxy-middleware": "^2.0.6",
|
||||
"ip-address": "^9.0.5",
|
||||
"js-base64": "^3.7.2",
|
||||
"jsrsasign": "^11.1.0",
|
||||
"lodash": "^4.17.21",
|
||||
|
||||
25
backend/pnpm-lock.yaml
generated
25
backend/pnpm-lock.yaml
generated
@@ -32,6 +32,9 @@ dependencies:
|
||||
http-proxy-middleware:
|
||||
specifier: ^2.0.6
|
||||
version: registry.npmmirror.com/http-proxy-middleware@2.0.6
|
||||
ip-address:
|
||||
specifier: ^9.0.5
|
||||
version: registry.npmmirror.com/ip-address@9.0.5
|
||||
js-base64:
|
||||
specifier: ^3.7.2
|
||||
version: registry.npmmirror.com/js-base64@3.7.2
|
||||
@@ -6031,6 +6034,16 @@ packages:
|
||||
engines: {node: '>=0.10.0'}
|
||||
dev: true
|
||||
|
||||
registry.npmmirror.com/ip-address@9.0.5:
|
||||
resolution: {integrity: sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/ip-address/-/ip-address-9.0.5.tgz}
|
||||
name: ip-address
|
||||
version: 9.0.5
|
||||
engines: {node: '>= 12'}
|
||||
dependencies:
|
||||
jsbn: registry.npmmirror.com/jsbn@1.1.0
|
||||
sprintf-js: registry.npmmirror.com/sprintf-js@1.1.3
|
||||
dev: false
|
||||
|
||||
registry.npmmirror.com/ip6addr@0.2.5:
|
||||
resolution: {integrity: sha512-9RGGSB6Zc9Ox5DpDGFnJdIeF0AsqXzdH+FspCfPPaU/L/4tI6P+5lIoFUFm9JXs9IrJv1boqAaNCQmoDADTSKQ==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/ip6addr/-/ip6addr-0.2.5.tgz}
|
||||
name: ip6addr
|
||||
@@ -6576,6 +6589,12 @@ packages:
|
||||
version: 0.1.1
|
||||
dev: false
|
||||
|
||||
registry.npmmirror.com/jsbn@1.1.0:
|
||||
resolution: {integrity: sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/jsbn/-/jsbn-1.1.0.tgz}
|
||||
name: jsbn
|
||||
version: 1.1.0
|
||||
dev: false
|
||||
|
||||
registry.npmmirror.com/jsesc@0.5.0:
|
||||
resolution: {integrity: sha512-uZz5UnB7u4T9LvwmFqXii7pZSouaRPorGs5who1Ip7VO0wxanFvBL7GkM6dTHlgX+jhBApRetaWpnDabOeTcnA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/jsesc/-/jsesc-0.5.0.tgz}
|
||||
name: jsesc
|
||||
@@ -9095,6 +9114,12 @@ packages:
|
||||
version: 1.0.3
|
||||
dev: false
|
||||
|
||||
registry.npmmirror.com/sprintf-js@1.1.3:
|
||||
resolution: {integrity: sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/sprintf-js/-/sprintf-js-1.1.3.tgz}
|
||||
name: sprintf-js
|
||||
version: 1.1.3
|
||||
dev: false
|
||||
|
||||
registry.npmmirror.com/sshpk@1.16.1:
|
||||
resolution: {integrity: sha512-HXXqVUq7+pcKeLqqZj6mHFUMvXtOJt1uoUx09pFW6011inTMxqI8BA8PM95myrIyyKwdnzjdFjLiE6KBPVtJIg==, registry: http://registry.npm.taobao.org/, tarball: https://registry.npmmirror.com/sshpk/-/sshpk-1.16.1.tgz}
|
||||
name: sshpk
|
||||
|
||||
@@ -2,7 +2,13 @@ import { Buffer } from 'buffer';
|
||||
import rs from '@/utils/rs';
|
||||
import YAML from '@/utils/yaml';
|
||||
import download from '@/utils/download';
|
||||
import { isIPv4, isIPv6, isValidPortNumber, isNotBlank } from '@/utils';
|
||||
import {
|
||||
isIPv4,
|
||||
isIPv6,
|
||||
isValidPortNumber,
|
||||
isNotBlank,
|
||||
ipAddress,
|
||||
} from '@/utils';
|
||||
import PROXY_PROCESSORS, { ApplyProcessor } from './processors';
|
||||
import PROXY_PREPROCESSORS from './preprocessors';
|
||||
import PROXY_PRODUCERS from './producers';
|
||||
@@ -267,6 +273,7 @@ export const ProxyUtils = {
|
||||
parse,
|
||||
process: processFn,
|
||||
produce,
|
||||
ipAddress,
|
||||
isIPv4,
|
||||
isIPv6,
|
||||
isIP,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import resourceCache from '@/utils/resource-cache';
|
||||
import scriptResourceCache from '@/utils/script-resource-cache';
|
||||
import { isIPv4, isIPv6 } from '@/utils';
|
||||
import { isIPv4, isIPv6, ipAddress } from '@/utils';
|
||||
import { FULL } from '@/utils/logical';
|
||||
import { getFlag, removeFlag } from '@/utils/geo';
|
||||
import { doh } from '@/utils/dns';
|
||||
@@ -360,10 +360,11 @@ function ScriptOperator(script, targetPlatform, $arguments, source) {
|
||||
};
|
||||
}
|
||||
|
||||
function parseIP4P(IP4P) {
|
||||
function parseIP4P(ip) {
|
||||
let server;
|
||||
let port;
|
||||
try {
|
||||
const IP4P = new ipAddress.Address6(ip).correctForm();
|
||||
if (!/^2001::[^:]+:[^:]+:[^:]+$/.test(IP4P)) {
|
||||
throw new Error(`Invalid IP4P: ${IP4P}`);
|
||||
}
|
||||
@@ -629,7 +630,7 @@ function ResolveDomainOperator({
|
||||
)
|
||||
]
|
||||
: results[p.server];
|
||||
if (_type === 'IP4P') {
|
||||
if (type === 'IPv6' && isIPv6(ip)) {
|
||||
const { server, port } = parseIP4P(ip);
|
||||
if (server && port) {
|
||||
p._domain = p.server;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import * as ipAddress from 'ip-address';
|
||||
// source: https://stackoverflow.com/a/36760050
|
||||
const IPV4_REGEX = /^((25[0-5]|(2[0-4]|1\d|[1-9]|)\d)(\.(?!$)|$)){4}$/;
|
||||
|
||||
@@ -94,6 +95,7 @@ function getPolicyDescriptor(str) {
|
||||
// })();
|
||||
|
||||
export {
|
||||
ipAddress,
|
||||
isIPv4,
|
||||
isIPv6,
|
||||
isValidPortNumber,
|
||||
|
||||
Reference in New Issue
Block a user