mirror of
https://github.com/sub-store-org/Sub-Store.git
synced 2025-08-10 00:52:40 +00:00
feat: IP4P 合并进 IPv6; ProxyUtils 中增加 ipAddress
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user