mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 06:23:44 +08:00
fix: type
This commit is contained in:
parent
ec6c2adf9b
commit
2f640a946e
63
src/services/types.d.ts
vendored
63
src/services/types.d.ts
vendored
@ -247,9 +247,20 @@ interface HttpOptions {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface H2Options {
|
||||||
|
path?: string;
|
||||||
|
host?: string;
|
||||||
|
}
|
||||||
|
|
||||||
interface GrpcOptions {
|
interface GrpcOptions {
|
||||||
"grpc-service-name"?: string;
|
"grpc-service-name"?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface RealityOptions {
|
||||||
|
"public-key"?: string;
|
||||||
|
"short-id"?: string;
|
||||||
|
}
|
||||||
|
|
||||||
type NetworkType = "ws" | "http" | "h2" | "grpc";
|
type NetworkType = "ws" | "http" | "h2" | "grpc";
|
||||||
|
|
||||||
// base
|
// base
|
||||||
@ -258,22 +269,22 @@ interface IProxyBaseConfig {
|
|||||||
mptcp?: boolean;
|
mptcp?: boolean;
|
||||||
"interface-name"?: string;
|
"interface-name"?: string;
|
||||||
"routing-mark"?: number;
|
"routing-mark"?: number;
|
||||||
"ip-version"?: string;
|
"ip-version"?: "dual" | "ipv4" | "ipv6" | "ipv4-prefer" | "ipv6-prefer";
|
||||||
"dialer-proxy"?: string;
|
"dialer-proxy"?: string;
|
||||||
}
|
}
|
||||||
// direct
|
// direct
|
||||||
interface IProxyDirectConfig extends IProxyBaseConfig {
|
interface IProxyDirectConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "direct";
|
type: "direct";
|
||||||
}
|
}
|
||||||
// dns
|
// dns
|
||||||
interface IProxyDnsConfig extends IProxyBaseConfig {
|
interface IProxyDnsConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "dns";
|
type: "dns";
|
||||||
}
|
}
|
||||||
// http
|
// http
|
||||||
interface IProxyHttpConfig extends IProxyBaseConfig {
|
interface IProxyHttpConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "http";
|
type: "http";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -287,7 +298,7 @@ interface IProxyHttpConfig extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// socks5
|
// socks5
|
||||||
interface IProxySocks5Config extends IProxyBaseConfig {
|
interface IProxySocks5Config extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "socks5";
|
type: "socks5";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -300,7 +311,7 @@ interface IProxySocks5Config extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// ssh
|
// ssh
|
||||||
interface IProxySshConfig extends IProxyBaseConfig {
|
interface IProxySshConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "ssh";
|
type: "ssh";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -313,7 +324,7 @@ interface IProxySshConfig extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// trojan
|
// trojan
|
||||||
interface IProxyTrojanConfig extends IProxyBaseConfig {
|
interface IProxyTrojanConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "trojan";
|
type: "trojan";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -324,7 +335,7 @@ interface IProxyTrojanConfig extends IProxyBaseConfig {
|
|||||||
fingerprint?: string;
|
fingerprint?: string;
|
||||||
udp?: boolean;
|
udp?: boolean;
|
||||||
network?: NetworkType;
|
network?: NetworkType;
|
||||||
"reality-opts"?: {};
|
"reality-opts"?: RealityOptions;
|
||||||
"grpc-opts"?: GrpcOptions;
|
"grpc-opts"?: GrpcOptions;
|
||||||
"ws-opts"?: WsOptions;
|
"ws-opts"?: WsOptions;
|
||||||
"ss-opts"?: {
|
"ss-opts"?: {
|
||||||
@ -336,7 +347,7 @@ interface IProxyTrojanConfig extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// tuic
|
// tuic
|
||||||
interface IProxyTuicConfig extends IProxyBaseConfig {
|
interface IProxyTuicConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "tuic";
|
type: "tuic";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -369,7 +380,7 @@ interface IProxyTuicConfig extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// vless
|
// vless
|
||||||
interface IProxyVlessConfig extends IProxyBaseConfig {
|
interface IProxyVlessConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "vless";
|
type: "vless";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -382,12 +393,9 @@ interface IProxyVlessConfig extends IProxyBaseConfig {
|
|||||||
xudp?: boolean;
|
xudp?: boolean;
|
||||||
"packet-encoding"?: string;
|
"packet-encoding"?: string;
|
||||||
network?: NetworkType;
|
network?: NetworkType;
|
||||||
"reality-opts"?: {
|
"reality-opts"?: RealityOptions;
|
||||||
"public-key"?: string;
|
|
||||||
"short-id"?: string;
|
|
||||||
};
|
|
||||||
"http-opts"?: HttpOptions;
|
"http-opts"?: HttpOptions;
|
||||||
"h2-opts"?: {};
|
"h2-opts"?: H2Options;
|
||||||
"grpc-opts"?: GrpcOptions;
|
"grpc-opts"?: GrpcOptions;
|
||||||
"ws-opts"?: WsOptions;
|
"ws-opts"?: WsOptions;
|
||||||
"ws-path"?: string;
|
"ws-path"?: string;
|
||||||
@ -399,7 +407,7 @@ interface IProxyVlessConfig extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// vmess
|
// vmess
|
||||||
interface IProxyVmessConfig extends IProxyBaseConfig {
|
interface IProxyVmessConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "vmess";
|
type: "vmess";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -413,12 +421,9 @@ interface IProxyVmessConfig extends IProxyBaseConfig {
|
|||||||
"skip-cert-verify"?: boolean;
|
"skip-cert-verify"?: boolean;
|
||||||
fingerprint?: string;
|
fingerprint?: string;
|
||||||
servername?: string;
|
servername?: string;
|
||||||
"reality-opts"?: {};
|
"reality-opts"?: RealityOptions;
|
||||||
"http-opts"?: HttpOptions;
|
"http-opts"?: HttpOptions;
|
||||||
"h2-opts"?: {
|
"h2-opts"?: H2Options;
|
||||||
path?: string;
|
|
||||||
host?: string;
|
|
||||||
};
|
|
||||||
"grpc-opts"?: GrpcOptions;
|
"grpc-opts"?: GrpcOptions;
|
||||||
"ws-opts"?: WsOptions;
|
"ws-opts"?: WsOptions;
|
||||||
"packet-addr"?: boolean;
|
"packet-addr"?: boolean;
|
||||||
@ -438,7 +443,7 @@ interface WireGuardPeerOptions {
|
|||||||
}
|
}
|
||||||
// wireguard
|
// wireguard
|
||||||
interface IProxyWireguardConfig extends IProxyBaseConfig, WireGuardPeerOptions {
|
interface IProxyWireguardConfig extends IProxyBaseConfig, WireGuardPeerOptions {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "wireguard";
|
type: "wireguard";
|
||||||
ip?: string;
|
ip?: string;
|
||||||
ipv6?: string;
|
ipv6?: string;
|
||||||
@ -454,7 +459,7 @@ interface IProxyWireguardConfig extends IProxyBaseConfig, WireGuardPeerOptions {
|
|||||||
}
|
}
|
||||||
// hysteria
|
// hysteria
|
||||||
interface IProxyHysteriaConfig extends IProxyBaseConfig {
|
interface IProxyHysteriaConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "hysteria";
|
type: "hysteria";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -482,7 +487,7 @@ interface IProxyHysteriaConfig extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// hysteria2
|
// hysteria2
|
||||||
interface IProxyHysteria2Config extends IProxyBaseConfig {
|
interface IProxyHysteria2Config extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "hysteria2";
|
type: "hysteria2";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -506,14 +511,14 @@ interface IProxyHysteria2Config extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// shadowsocks
|
// shadowsocks
|
||||||
interface IProxyShadowsocksConfig extends IProxyBaseConfig {
|
interface IProxyShadowsocksConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "ss";
|
type: "ss";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
password?: string;
|
password?: string;
|
||||||
cipher?: string;
|
cipher?: string;
|
||||||
udp?: boolean;
|
udp?: boolean;
|
||||||
plugin?: string;
|
plugin?: "obfs" | "v2ray-plugin" | "shadow-tls" | "restls";
|
||||||
"plugin-opts"?: {
|
"plugin-opts"?: {
|
||||||
mode?: string;
|
mode?: string;
|
||||||
host?: string;
|
host?: string;
|
||||||
@ -536,7 +541,7 @@ interface IProxyShadowsocksConfig extends IProxyBaseConfig {
|
|||||||
}
|
}
|
||||||
// shadowsocksR
|
// shadowsocksR
|
||||||
interface IProxyshadowsocksRConfig extends IProxyBaseConfig {
|
interface IProxyshadowsocksRConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "ssr";
|
type: "ssr";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
@ -552,7 +557,7 @@ interface IProxyshadowsocksRConfig extends IProxyBaseConfig {
|
|||||||
interface IProxySmuxConfig {
|
interface IProxySmuxConfig {
|
||||||
smux?: {
|
smux?: {
|
||||||
enabled?: boolean;
|
enabled?: boolean;
|
||||||
protocol?: string;
|
protocol?: "smux" | "yamux" | "h2mux";
|
||||||
"max-connections"?: number;
|
"max-connections"?: number;
|
||||||
"min-streams"?: number;
|
"min-streams"?: number;
|
||||||
"max-streams"?: number;
|
"max-streams"?: number;
|
||||||
@ -568,7 +573,7 @@ interface IProxySmuxConfig {
|
|||||||
}
|
}
|
||||||
// snell
|
// snell
|
||||||
interface IProxySnellConfig extends IProxyBaseConfig {
|
interface IProxySnellConfig extends IProxyBaseConfig {
|
||||||
name?: string;
|
name: string;
|
||||||
type: "snell";
|
type: "snell";
|
||||||
server?: string;
|
server?: string;
|
||||||
port?: number;
|
port?: number;
|
||||||
|
@ -85,7 +85,7 @@ function URI_SS(line: string): IProxyShadowsocksConfig {
|
|||||||
let content = line.split("ss://")[1];
|
let content = line.split("ss://")[1];
|
||||||
|
|
||||||
const proxy: IProxyShadowsocksConfig = {
|
const proxy: IProxyShadowsocksConfig = {
|
||||||
name: trimStr(decodeURIComponent(line.split("#")[1])),
|
name: decodeURIComponent(line.split("#")[1]).trim(),
|
||||||
type: "ss",
|
type: "ss",
|
||||||
server: "",
|
server: "",
|
||||||
port: 0,
|
port: 0,
|
||||||
@ -124,9 +124,7 @@ function URI_SS(line: string): IProxyShadowsocksConfig {
|
|||||||
proxy.port = parseInt(
|
proxy.port = parseInt(
|
||||||
`${serverAndPort?.substring(portIdx + 1)}`.match(/\d+/)?.[0] ?? ""
|
`${serverAndPort?.substring(portIdx + 1)}`.match(/\d+/)?.[0] ?? ""
|
||||||
);
|
);
|
||||||
console.log(userInfoStr);
|
|
||||||
const userInfo = userInfoStr.match(/(^.*?):(.*$)/);
|
const userInfo = userInfoStr.match(/(^.*?):(.*$)/);
|
||||||
console.log(userInfo);
|
|
||||||
proxy.cipher = userInfo?.[1];
|
proxy.cipher = userInfo?.[1];
|
||||||
proxy.password = userInfo?.[2];
|
proxy.password = userInfo?.[2];
|
||||||
|
|
||||||
@ -214,8 +212,8 @@ function URI_SSR(line: string): IProxyshadowsocksRConfig {
|
|||||||
proxy = {
|
proxy = {
|
||||||
...proxy,
|
...proxy,
|
||||||
name: other_params.remarks
|
name: other_params.remarks
|
||||||
? trimStr(decodeBase64OrOriginal(other_params.remarks))
|
? decodeBase64OrOriginal(other_params.remarks).trim()
|
||||||
: proxy.server,
|
: proxy.server ?? "",
|
||||||
"protocol-param": getIfNotBlank(
|
"protocol-param": getIfNotBlank(
|
||||||
decodeBase64OrOriginal(other_params.protoparam || "").replace(/\s/g, "")
|
decodeBase64OrOriginal(other_params.protoparam || "").replace(/\s/g, "")
|
||||||
),
|
),
|
||||||
@ -229,11 +227,9 @@ function URI_SSR(line: string): IProxyshadowsocksRConfig {
|
|||||||
function URI_VMESS(line: string): IProxyVmessConfig {
|
function URI_VMESS(line: string): IProxyVmessConfig {
|
||||||
line = line.split("vmess://")[1];
|
line = line.split("vmess://")[1];
|
||||||
let content = decodeBase64OrOriginal(line);
|
let content = decodeBase64OrOriginal(line);
|
||||||
console.log(content);
|
|
||||||
if (/=\s*vmess/.test(content)) {
|
if (/=\s*vmess/.test(content)) {
|
||||||
// Quantumult VMess URI format
|
// Quantumult VMess URI format
|
||||||
const partitions = content.split(",").map((p) => p.trim());
|
const partitions = content.split(",").map((p) => p.trim());
|
||||||
console.log(partitions);
|
|
||||||
const params: Record<string, string> = {};
|
const params: Record<string, string> = {};
|
||||||
for (const part of partitions) {
|
for (const part of partitions) {
|
||||||
if (part.indexOf("=") !== -1) {
|
if (part.indexOf("=") !== -1) {
|
||||||
@ -243,7 +239,7 @@ function URI_VMESS(line: string): IProxyVmessConfig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const proxy: IProxyVmessConfig = {
|
const proxy: IProxyVmessConfig = {
|
||||||
name: trimStr(partitions[0].split("=")[0]),
|
name: partitions[0].split("=")[0].trim(),
|
||||||
type: "vmess",
|
type: "vmess",
|
||||||
server: partitions[1],
|
server: partitions[1],
|
||||||
port: parseInt(partitions[2], 10),
|
port: parseInt(partitions[2], 10),
|
||||||
@ -571,7 +567,7 @@ function URI_Trojan(line: string): IProxyTrojanConfig {
|
|||||||
const proxy: IProxyTrojanConfig = parser.parse(newLine);
|
const proxy: IProxyTrojanConfig = parser.parse(newLine);
|
||||||
if (isNotBlank(name)) {
|
if (isNotBlank(name)) {
|
||||||
try {
|
try {
|
||||||
proxy.name = trimStr(decodeURIComponent(name));
|
proxy.name = decodeURIComponent(name).trim();
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
throw Error("Can not get proxy name");
|
throw Error("Can not get proxy name");
|
||||||
}
|
}
|
||||||
@ -926,7 +922,19 @@ function URI_HTTP(line: string): IProxyHttpConfig {
|
|||||||
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
proxy["skip-cert-verify"] = /(TRUE)|1/i.test(value);
|
||||||
break;
|
break;
|
||||||
case "ip-version":
|
case "ip-version":
|
||||||
proxy["ip-version"] = value;
|
if (
|
||||||
|
["dual", "ipv4", "ipv6", "ipv4-prefer", "ipv6-prefer"].includes(value)
|
||||||
|
) {
|
||||||
|
proxy["ip-version"] = value as
|
||||||
|
| "dual"
|
||||||
|
| "ipv4"
|
||||||
|
| "ipv6"
|
||||||
|
| "ipv4-prefer"
|
||||||
|
| "ipv6-prefer";
|
||||||
|
} else {
|
||||||
|
proxy["ip-version"] = "dual";
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
@ -980,7 +988,18 @@ function URI_SOCKS(line: string): IProxySocks5Config {
|
|||||||
proxy["udp"] = /(TRUE)|1/i.test(value);
|
proxy["udp"] = /(TRUE)|1/i.test(value);
|
||||||
break;
|
break;
|
||||||
case "ip-version":
|
case "ip-version":
|
||||||
proxy["ip-version"] = value;
|
if (
|
||||||
|
["dual", "ipv4", "ipv6", "ipv4-prefer", "ipv6-prefer"].includes(value)
|
||||||
|
) {
|
||||||
|
proxy["ip-version"] = value as
|
||||||
|
| "dual"
|
||||||
|
| "ipv4"
|
||||||
|
| "ipv6"
|
||||||
|
| "ipv4-prefer"
|
||||||
|
| "ipv6-prefer";
|
||||||
|
} else {
|
||||||
|
proxy["ip-version"] = "dual";
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user