mirror of
https://github.com/clash-verge-rev/clash-verge-rev
synced 2025-05-05 05:53:44 +08:00
162 lines
3.0 KiB
TypeScript
162 lines
3.0 KiB
TypeScript
/**
|
|
* Some interface for clash api
|
|
*/
|
|
export namespace ApiType {
|
|
export interface ConfigData {
|
|
port: number;
|
|
mode: string;
|
|
ipv6: boolean;
|
|
"socket-port": number;
|
|
"allow-lan": boolean;
|
|
"log-level": string;
|
|
"mixed-port": number;
|
|
"redir-port": number;
|
|
"socks-port": number;
|
|
"tproxy-port": number;
|
|
}
|
|
|
|
export interface RuleItem {
|
|
type: string;
|
|
payload: string;
|
|
proxy: string;
|
|
}
|
|
|
|
export interface ProxyItem {
|
|
name: string;
|
|
type: string;
|
|
udp: boolean;
|
|
history: {
|
|
time: string;
|
|
delay: number;
|
|
}[];
|
|
all?: string[];
|
|
now?: string;
|
|
}
|
|
|
|
export type ProxyGroupItem = Omit<ProxyItem, "all"> & {
|
|
all: ProxyItem[];
|
|
};
|
|
|
|
export interface TrafficItem {
|
|
up: number;
|
|
down: number;
|
|
}
|
|
|
|
export interface LogItem {
|
|
type: string;
|
|
time?: string;
|
|
payload: string;
|
|
}
|
|
|
|
export interface ConnectionsItem {
|
|
id: string;
|
|
metadata: {
|
|
network: string;
|
|
type: string;
|
|
host: string;
|
|
sourceIP: string;
|
|
sourcePort: string;
|
|
destinationPort: string;
|
|
destinationIP?: string;
|
|
};
|
|
upload: number;
|
|
download: number;
|
|
start: string;
|
|
chains: string[];
|
|
rule: string;
|
|
rulePayload: string;
|
|
}
|
|
|
|
export interface Connections {
|
|
downloadTotal: number;
|
|
uploadTotal: number;
|
|
connections: ConnectionsItem[];
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Some interface for command
|
|
*/
|
|
export namespace CmdType {
|
|
export type ProfileType = "local" | "remote" | "merge" | "script";
|
|
|
|
export interface ClashInfo {
|
|
status: string;
|
|
port?: string;
|
|
server?: string;
|
|
secret?: string;
|
|
}
|
|
|
|
export interface ProfileItem {
|
|
uid: string;
|
|
type?: ProfileType | string;
|
|
name?: string;
|
|
desc?: string;
|
|
file?: string;
|
|
url?: string;
|
|
updated?: number;
|
|
selected?: {
|
|
name?: string;
|
|
now?: string;
|
|
}[];
|
|
extra?: {
|
|
upload: number;
|
|
download: number;
|
|
total: number;
|
|
expire: number;
|
|
};
|
|
option?: ProfileOption;
|
|
}
|
|
|
|
export interface ProfileOption {
|
|
user_agent?: string;
|
|
with_proxy?: boolean;
|
|
}
|
|
|
|
export interface ProfilesConfig {
|
|
current?: string;
|
|
chain?: string[];
|
|
items?: ProfileItem[];
|
|
}
|
|
|
|
export interface VergeConfig {
|
|
theme_mode?: "light" | "dark";
|
|
theme_blur?: boolean;
|
|
traffic_graph?: boolean;
|
|
enable_tun_mode?: boolean;
|
|
enable_auto_launch?: boolean;
|
|
enable_system_proxy?: boolean;
|
|
enable_proxy_guard?: boolean;
|
|
system_proxy_bypass?: string;
|
|
}
|
|
|
|
export type ProfileMerge = Record<string, any>;
|
|
|
|
// partial of the clash config
|
|
export type ProfileData = Partial<{
|
|
rules: any[];
|
|
proxies: any[];
|
|
"proxy-groups": any[];
|
|
"proxy-providers": any[];
|
|
"rule-providers": any[];
|
|
}>;
|
|
|
|
export interface ChainItem {
|
|
item: ProfileItem;
|
|
merge?: ProfileMerge;
|
|
script?: string;
|
|
}
|
|
|
|
export interface EnhancedPayload {
|
|
chain: ChainItem[];
|
|
current: ProfileData;
|
|
callback: string;
|
|
}
|
|
|
|
export interface EnhancedResult {
|
|
data: ProfileData;
|
|
status: string;
|
|
error?: string;
|
|
}
|
|
}
|