mihomo-party/src/shared/types.d.ts
2024-08-07 09:51:04 +08:00

204 lines
4.0 KiB
TypeScript

type OutboundMode = 'rule' | 'global' | 'direct'
type LogLevel = 'info' | 'debug' | 'warning' | 'error' | 'silent'
type SysProxyMode = 'auto' | 'manual'
type MihomoGroupType = 'Selector'
type MihomoProxyType = 'Shadowsocks'
interface IMihomoVersion {
version: string
meta: boolean
}
interface IMihomoTrafficInfo {
up: number
down: number
}
interface IMihomoLogInfo {
type: LogLevel
payload: string
time?: string
}
interface IMihomoRulesInfo {
rules: IMihomoRulesDetail[]
}
interface IMihomoRulesDetail {
type: string
payload: string
proxy: string
size: number
}
interface IMihomoConnectionsInfo {
downloadTotal: number
uploadTotal: number
connections?: IMihomoConnectionDetail[]
memory: number
}
interface IMihomoConnectionDetail {
id: string
metadata: {
network: 'tcp' | 'udp'
type: string
sourceIP: string
destinationIP: string
destinationGeoIP: string
destinationIPASN: string
sourcePort: string
destinationPort: string
inboundIP: string
inboundPort: string
inboundName: string
inboundUser: string
host: string
dnsMode: string
uid: number
process: string
processPath: string
specialProxy: string
specialRules: string
remoteDestination: string
dscp: number
sniffHost: string
}
upload: number
download: number
start: string
chains: string[]
rule: string
rulePayload: string
}
interface IMihomoHistory {
time: string
delay: number
}
interface IMihomoDelay {
delay?: number
message?: string
}
interface IMihomoProxy {
alive: boolean
extra: Record<string, { alive: boolean; history: IMihomoHistory[] }>
history: IMihomoHistory[]
id: string
name: string
tfo: boolean
type: MihomoProxyType
udp: boolean
xudp: boolean
}
interface IMihomoGroup {
alive: boolean
all: string[]
extra: Record<string, { alive: boolean; history: IMihomoHistory[] }>
testUrl?: string
hidden: boolean
history: IMihomoHistory[]
icon: string
name: string
now: string
tfo: boolean
type: MihomoGroupType
udp: boolean
xudp: boolean
}
interface IMihomoProxies {
proxies: Record<string, IMihomoProxy | IMihomoGroup>
}
interface ISysProxyConfig {
enable: boolean
host?: string
mode?: SysProxyMode
bypass?: string[]
pacScript?: string
}
interface IAppConfig {
core: 'mihomo' | 'mihomo-alpha'
proxyDisplayMode: 'simple' | 'full'
silentStart: boolean
sysProxy: ISysProxyConfig
userAgent?: string
delayTestUrl?: string
delayTestTimeout?: number
}
interface IMihomoTunConfig {
enable: boolean
stack?: 'system' | 'gvisor' | 'mixed'
'auto-route'?: boolean
'auto-redirect'?: boolean
'auto-detect-interface'?: boolean
'dns-hijack'?: string[]
device?: string
mtu?: number
'strict-route'?: boolean
gso?: boolean
'gso-max-size'?: number
'udp-timeout'?: number
'iproute2-table-index'?: number
'iproute2-rule-index'?: number
'endpoint-independent-nat'?: boolean
'route-address-set'?: string[]
'route-exclude-address-set'?: string[]
'route-address'?: string[]
'route-exclude-address'?: string[]
'include-interface'?: string[]
'exclude-interface'?: string[]
'include-uid'?: number[]
'include-uid-range'?: string[]
'exclude-uid'?: number[]
'exclude-uid-range'?: string[]
'include-android-user'?: string[]
'include-package'?: string[]
'exclude-package'?: string[]
}
interface IMihomoConfig {
'external-controller': string
secret?: string
ipv6: boolean
mode: OutboundMode
'mixed-port': number
'allow-lan': boolean
'log-level': LogLevel
'socks-port'?: number
port?: number
proxies?: []
'proxy-groups'?: []
rules?: []
tun: IMihomoTunConfig
}
interface IProfileConfig {
current?: string
items: IProfileItem[]
}
interface ISubscriptionUserInfo {
upload: number
download: number
total: number
expire: number
}
interface IProfileItem {
id: string
type: 'remote' | 'local'
name: string
url?: string // remote
file?: string // local
interval?: number
home?: string
updated?: number
extra?: ISubscriptionUserInfo
}