types.d.ts 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681
  1. type Platform =
  2. | "aix"
  3. | "android"
  4. | "darwin"
  5. | "freebsd"
  6. | "haiku"
  7. | "linux"
  8. | "openbsd"
  9. | "sunos"
  10. | "win32"
  11. | "cygwin"
  12. | "netbsd";
  13. /**
  14. * defines in `vite.config.ts`
  15. */
  16. declare const OS_PLATFORM: Platform;
  17. /**
  18. * Some interface for clash api
  19. */
  20. interface IConfigData {
  21. port: number;
  22. mode: string;
  23. ipv6: boolean;
  24. "socket-port": number;
  25. "allow-lan": boolean;
  26. "log-level": string;
  27. "mixed-port": number;
  28. "redir-port": number;
  29. "socks-port": number;
  30. "tproxy-port": number;
  31. "external-controller": string;
  32. secret: string;
  33. tun: {
  34. stack: string;
  35. device: string;
  36. "auto-route": boolean;
  37. "auto-detect-interface": boolean;
  38. "dns-hijack": string[];
  39. "strict-route": boolean;
  40. mtu: number;
  41. };
  42. }
  43. interface IRuleItem {
  44. type: string;
  45. payload: string;
  46. proxy: string;
  47. }
  48. interface IProxyItem {
  49. name: string;
  50. type: string;
  51. udp: boolean;
  52. xudp: boolean;
  53. tfo: boolean;
  54. history: {
  55. time: string;
  56. delay: number;
  57. }[];
  58. all?: string[];
  59. now?: string;
  60. hidden?: boolean;
  61. icon?: string;
  62. provider?: string; // 记录是否来自provider
  63. fixed?: string; // 记录固定(优先)的节点
  64. }
  65. type IProxyGroupItem = Omit<IProxyItem, "all"> & {
  66. all: IProxyItem[];
  67. };
  68. interface IProxyProviderItem {
  69. name: string;
  70. type: string;
  71. proxies: IProxyItem[];
  72. updatedAt: string;
  73. vehicleType: string;
  74. subscriptionInfo?: {
  75. Upload: number;
  76. Download: number;
  77. Total: number;
  78. Expire: number;
  79. };
  80. }
  81. interface IRuleProviderItem {
  82. name: string;
  83. behavior: string;
  84. format: string;
  85. ruleCount: number;
  86. type: string;
  87. updatedAt: string;
  88. vehicleType: string;
  89. }
  90. interface ITrafficItem {
  91. up: number;
  92. down: number;
  93. }
  94. interface ILogItem {
  95. type: string;
  96. time?: string;
  97. payload: string;
  98. }
  99. interface IConnectionsItem {
  100. id: string;
  101. metadata: {
  102. network: string;
  103. type: string;
  104. host: string;
  105. sourceIP: string;
  106. sourcePort: string;
  107. destinationPort: string;
  108. destinationIP?: string;
  109. process?: string;
  110. processPath?: string;
  111. };
  112. upload: number;
  113. download: number;
  114. start: string;
  115. chains: string[];
  116. rule: string;
  117. rulePayload: string;
  118. curUpload?: number; // upload speed, calculate at runtime
  119. curDownload?: number; // download speed, calculate at runtime
  120. }
  121. interface IConnections {
  122. downloadTotal: number;
  123. uploadTotal: number;
  124. connections: IConnectionsItem[];
  125. }
  126. /**
  127. * Some interface for command
  128. */
  129. interface IClashInfo {
  130. // status: string;
  131. mixed_port?: number; // clash mixed port
  132. socks_port?: number; // clash socks port
  133. redir_port?: number; // clash redir port
  134. tproxy_port?: number; // clash tproxy port
  135. port?: number; // clash http port
  136. server?: string; // external-controller
  137. secret?: string;
  138. }
  139. interface IProfileItem {
  140. uid: string;
  141. type?: "local" | "remote" | "merge" | "script";
  142. name?: string;
  143. desc?: string;
  144. file?: string;
  145. url?: string;
  146. updated?: number;
  147. selected?: {
  148. name?: string;
  149. now?: string;
  150. }[];
  151. extra?: {
  152. upload: number;
  153. download: number;
  154. total: number;
  155. expire: number;
  156. };
  157. option?: IProfileOption;
  158. home?: string;
  159. }
  160. interface IProfileOption {
  161. user_agent?: string;
  162. with_proxy?: boolean;
  163. self_proxy?: boolean;
  164. update_interval?: number;
  165. danger_accept_invalid_certs?: boolean;
  166. merge?: string;
  167. script?: string;
  168. rules?: string;
  169. proxies?: string;
  170. groups?: string;
  171. }
  172. interface IProfilesConfig {
  173. current?: string;
  174. valid?: string[];
  175. items?: IProfileItem[];
  176. }
  177. interface IVergeTestItem {
  178. uid: string;
  179. name?: string;
  180. icon?: string;
  181. url: string;
  182. }
  183. interface ISeqProfileConfig {
  184. prepend: [];
  185. append: [];
  186. delete: [];
  187. }
  188. interface IProxyGroupConfig {
  189. name: string;
  190. type: "select" | "url-test" | "fallback" | "load-balance" | "relay";
  191. proxies?: string[];
  192. use?: string[];
  193. url?: string;
  194. interval?: number;
  195. lazy?: boolean;
  196. timeout?: number;
  197. "max-failed-times"?: number;
  198. "disable-udp"?: boolean;
  199. "interface-name": string;
  200. "routing-mark"?: number;
  201. "include-all"?: boolean;
  202. "include-all-proxies"?: boolean;
  203. "include-all-providers"?: boolean;
  204. filter?: string;
  205. "exclude-filter"?: string;
  206. "exclude-type"?: string;
  207. "expected-status"?: string;
  208. hidden?: boolean;
  209. icon?: string;
  210. }
  211. interface WsOptions {
  212. path?: string;
  213. headers?: {
  214. [key: string]: string;
  215. };
  216. "max-early-data"?: number;
  217. "early-data-header-name"?: string;
  218. "v2ray-http-upgrade"?: boolean;
  219. "v2ray-http-upgrade-fast-open"?: boolean;
  220. }
  221. interface HttpOptions {
  222. method?: string;
  223. path?: string[];
  224. headers?: {
  225. [key: string]: string;
  226. };
  227. }
  228. interface H2Options {
  229. path?: string;
  230. host?: string;
  231. }
  232. interface GrpcOptions {
  233. "grpc-service-name"?: string;
  234. }
  235. interface RealityOptions {
  236. "public-key"?: string;
  237. "short-id"?: string;
  238. }
  239. type NetworkType = "ws" | "http" | "h2" | "grpc";
  240. // base
  241. interface IProxyBaseConfig {
  242. tfo?: boolean;
  243. mptcp?: boolean;
  244. "interface-name"?: string;
  245. "routing-mark"?: number;
  246. "ip-version"?: "dual" | "ipv4" | "ipv6" | "ipv4-prefer" | "ipv6-prefer";
  247. "dialer-proxy"?: string;
  248. }
  249. // direct
  250. interface IProxyDirectConfig extends IProxyBaseConfig {
  251. name: string;
  252. type: "direct";
  253. }
  254. // dns
  255. interface IProxyDnsConfig extends IProxyBaseConfig {
  256. name: string;
  257. type: "dns";
  258. }
  259. // http
  260. interface IProxyHttpConfig extends IProxyBaseConfig {
  261. name: string;
  262. type: "http";
  263. server?: string;
  264. port?: number;
  265. username?: string;
  266. password?: string;
  267. tls?: boolean;
  268. sni?: string;
  269. "skip-cert-verify"?: boolean;
  270. fingerprint?: string;
  271. headers?: {};
  272. }
  273. // socks5
  274. interface IProxySocks5Config extends IProxyBaseConfig {
  275. name: string;
  276. type: "socks5";
  277. server?: string;
  278. port?: number;
  279. username?: string;
  280. password?: string;
  281. tls?: boolean;
  282. udp?: boolean;
  283. "skip-cert-verify"?: boolean;
  284. fingerprint?: string;
  285. }
  286. // ssh
  287. interface IProxySshConfig extends IProxyBaseConfig {
  288. name: string;
  289. type: "ssh";
  290. server?: string;
  291. port?: number;
  292. username?: string;
  293. password?: string;
  294. "private-key"?: string;
  295. "private-key-passphrase"?: string;
  296. "host-key"?: string;
  297. "host-key-algorithms"?: string;
  298. }
  299. // trojan
  300. interface IProxyTrojanConfig extends IProxyBaseConfig {
  301. name: string;
  302. type: "trojan";
  303. server?: string;
  304. port?: number;
  305. password?: string;
  306. alpn?: string[];
  307. sni?: string;
  308. "skip-cert-verify"?: boolean;
  309. fingerprint?: string;
  310. udp?: boolean;
  311. network?: NetworkType;
  312. "reality-opts"?: RealityOptions;
  313. "grpc-opts"?: GrpcOptions;
  314. "ws-opts"?: WsOptions;
  315. "ss-opts"?: {
  316. enabled?: boolean;
  317. method?: string;
  318. password?: string;
  319. };
  320. "client-fingerprint"?: string;
  321. }
  322. // tuic
  323. interface IProxyTuicConfig extends IProxyBaseConfig {
  324. name: string;
  325. type: "tuic";
  326. server?: string;
  327. port?: number;
  328. token?: string;
  329. uuid?: string;
  330. password?: string;
  331. ip?: string;
  332. "heartbeat-interval"?: number;
  333. alpn?: string[];
  334. "reduce-rtt"?: boolean;
  335. "request-timeout"?: number;
  336. "udp-relay-mode"?: string;
  337. "congestion-controller"?: string;
  338. "disable-sni"?: boolean;
  339. "max-udp-relay-packet-size"?: number;
  340. "fast-open"?: boolean;
  341. "max-open-streams"?: number;
  342. cwnd?: number;
  343. "skip-cert-verify"?: boolean;
  344. fingerprint?: string;
  345. ca?: string;
  346. "ca-str"?: string;
  347. "recv-window-conn"?: number;
  348. "recv-window"?: number;
  349. "disable-mtu-discovery"?: boolean;
  350. "max-datagram-frame-size"?: number;
  351. sni?: string;
  352. "udp-over-stream"?: boolean;
  353. "udp-over-stream-version"?: number;
  354. }
  355. // vless
  356. interface IProxyVlessConfig extends IProxyBaseConfig {
  357. name: string;
  358. type: "vless";
  359. server?: string;
  360. port?: number;
  361. uuid?: string;
  362. flow?: string;
  363. tls?: boolean;
  364. alpn?: string[];
  365. udp?: boolean;
  366. "packet-addr"?: boolean;
  367. xudp?: boolean;
  368. "packet-encoding"?: string;
  369. network?: NetworkType;
  370. "reality-opts"?: RealityOptions;
  371. "http-opts"?: HttpOptions;
  372. "h2-opts"?: H2Options;
  373. "grpc-opts"?: GrpcOptions;
  374. "ws-opts"?: WsOptions;
  375. "ws-path"?: string;
  376. "ws-headers"?: {};
  377. "skip-cert-verify"?: boolean;
  378. fingerprint?: string;
  379. servername?: string;
  380. "client-fingerprint"?: string;
  381. }
  382. // vmess
  383. interface IProxyVmessConfig extends IProxyBaseConfig {
  384. name: string;
  385. type: "vmess";
  386. server?: string;
  387. port?: number;
  388. uuid?: string;
  389. alterId?: number;
  390. cipher?: string;
  391. udp?: boolean;
  392. network?: NetworkType;
  393. tls?: boolean;
  394. alpn?: string[];
  395. "skip-cert-verify"?: boolean;
  396. fingerprint?: string;
  397. servername?: string;
  398. "reality-opts"?: RealityOptions;
  399. "http-opts"?: HttpOptions;
  400. "h2-opts"?: H2Options;
  401. "grpc-opts"?: GrpcOptions;
  402. "ws-opts"?: WsOptions;
  403. "packet-addr"?: boolean;
  404. xudp?: boolean;
  405. "packet-encoding"?: string;
  406. "global-padding"?: boolean;
  407. "authenticated-length"?: boolean;
  408. "client-fingerprint"?: string;
  409. }
  410. interface WireGuardPeerOptions {
  411. server?: string;
  412. port?: number;
  413. "public-key"?: string;
  414. "pre-shared-key"?: string;
  415. reserved?: number[];
  416. "allowed-ips"?: string[];
  417. }
  418. // wireguard
  419. interface IProxyWireguardConfig extends IProxyBaseConfig, WireGuardPeerOptions {
  420. name: string;
  421. type: "wireguard";
  422. ip?: string;
  423. ipv6?: string;
  424. "private-key"?: string;
  425. workers?: number;
  426. mtu?: number;
  427. udp?: boolean;
  428. "persistent-keepalive"?: number;
  429. peers?: WireGuardPeerOptions[];
  430. "remote-dns-resolve"?: boolean;
  431. dns?: string[];
  432. "refresh-server-ip-interval"?: number;
  433. }
  434. // hysteria
  435. interface IProxyHysteriaConfig extends IProxyBaseConfig {
  436. name: string;
  437. type: "hysteria";
  438. server?: string;
  439. port?: number;
  440. ports?: string;
  441. protocol?: string;
  442. "obfs-protocol"?: string;
  443. up?: string;
  444. "up-speed"?: number;
  445. down?: string;
  446. "down-speed"?: number;
  447. auth?: string;
  448. "auth-str"?: string;
  449. obfs?: string;
  450. sni?: string;
  451. "skip-cert-verify"?: boolean;
  452. fingerprint?: string;
  453. alpn?: string[];
  454. ca?: string;
  455. "ca-str"?: string;
  456. "recv-window-conn"?: number;
  457. "recv-window"?: number;
  458. "disable-mtu-discovery"?: boolean;
  459. "fast-open"?: boolean;
  460. "hop-interval"?: number;
  461. }
  462. // hysteria2
  463. interface IProxyHysteria2Config extends IProxyBaseConfig {
  464. name: string;
  465. type: "hysteria2";
  466. server?: string;
  467. port?: number;
  468. ports?: string;
  469. "hop-interval"?: number;
  470. protocol?: string;
  471. "obfs-protocol"?: string;
  472. up?: string;
  473. down?: string;
  474. password?: string;
  475. obfs?: string;
  476. "obfs-password"?: string;
  477. sni?: string;
  478. "skip-cert-verify"?: boolean;
  479. fingerprint?: string;
  480. alpn?: string[];
  481. ca?: string;
  482. "ca-str"?: string;
  483. cwnd?: number;
  484. "udp-mtu"?: number;
  485. }
  486. // shadowsocks
  487. interface IProxyShadowsocksConfig extends IProxyBaseConfig {
  488. name: string;
  489. type: "ss";
  490. server?: string;
  491. port?: number;
  492. password?: string;
  493. cipher?: string;
  494. udp?: boolean;
  495. plugin?: "obfs" | "v2ray-plugin" | "shadow-tls" | "restls";
  496. "plugin-opts"?: {
  497. mode?: string;
  498. host?: string;
  499. password?: string;
  500. path?: string;
  501. tls?: string;
  502. fingerprint?: string;
  503. headers?: {};
  504. "skip-cert-verify"?: boolean;
  505. version?: number;
  506. mux?: boolean;
  507. "v2ray-http-upgrade"?: boolean;
  508. "v2ray-http-upgrade-fast-open"?: boolean;
  509. "version-hint"?: string;
  510. "restls-script"?: string;
  511. };
  512. "udp-over-tcp"?: boolean;
  513. "udp-over-tcp-version"?: number;
  514. "client-fingerprint"?: string;
  515. }
  516. // shadowsocksR
  517. interface IProxyshadowsocksRConfig extends IProxyBaseConfig {
  518. name: string;
  519. type: "ssr";
  520. server?: string;
  521. port?: number;
  522. password?: string;
  523. cipher?: string;
  524. obfs?: string;
  525. "obfs-param"?: string;
  526. protocol?: string;
  527. "protocol-param"?: string;
  528. udp?: boolean;
  529. }
  530. // sing-mux
  531. interface IProxySmuxConfig {
  532. smux?: {
  533. enabled?: boolean;
  534. protocol?: "smux" | "yamux" | "h2mux";
  535. "max-connections"?: number;
  536. "min-streams"?: number;
  537. "max-streams"?: number;
  538. padding?: boolean;
  539. statistic?: boolean;
  540. "only-tcp"?: boolean;
  541. "brutal-opts"?: {
  542. enabled?: boolean;
  543. up?: string;
  544. down?: string;
  545. };
  546. };
  547. }
  548. // snell
  549. interface IProxySnellConfig extends IProxyBaseConfig {
  550. name: string;
  551. type: "snell";
  552. server?: string;
  553. port?: number;
  554. psk?: string;
  555. udp?: boolean;
  556. version?: number;
  557. "obfs-opts"?: {};
  558. }
  559. interface IProxyConfig
  560. extends IProxyBaseConfig,
  561. IProxyDirectConfig,
  562. IProxyDnsConfig,
  563. IProxyHttpConfig,
  564. IProxySocks5Config,
  565. IProxySshConfig,
  566. IProxyTrojanConfig,
  567. IProxyTuicConfig,
  568. IProxyVlessConfig,
  569. IProxyVmessConfig,
  570. IProxyWireguardConfig,
  571. IProxyHysteriaConfig,
  572. IProxyHysteria2Config,
  573. IProxyShadowsocksConfig,
  574. IProxyshadowsocksRConfig,
  575. IProxySmuxConfig,
  576. IProxySnellConfig {
  577. type:
  578. | "ss"
  579. | "ssr"
  580. | "direct"
  581. | "dns"
  582. | "snell"
  583. | "http"
  584. | "trojan"
  585. | "hysteria"
  586. | "hysteria2"
  587. | "tuic"
  588. | "wireguard"
  589. | "ssh"
  590. | "socks5"
  591. | "vmess"
  592. | "vless";
  593. }
  594. interface IVergeConfig {
  595. app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string;
  596. language?: string;
  597. tray_event?: "main_window" | "system_proxy" | "tun_mode" | string;
  598. env_type?: "bash" | "cmd" | "powershell" | string;
  599. startup_script?: string;
  600. start_page?: string;
  601. clash_core?: string;
  602. theme_mode?: "light" | "dark" | "system";
  603. traffic_graph?: boolean;
  604. enable_memory_usage?: boolean;
  605. enable_group_icon?: boolean;
  606. menu_icon?: "monochrome" | "colorful" | "disable";
  607. tray_icon?: "monochrome" | "colorful";
  608. common_tray_icon?: boolean;
  609. sysproxy_tray_icon?: boolean;
  610. tun_tray_icon?: boolean;
  611. enable_tun_mode?: boolean;
  612. enable_auto_launch?: boolean;
  613. enable_service_mode?: boolean;
  614. enable_silent_start?: boolean;
  615. enable_system_proxy?: boolean;
  616. proxy_auto_config?: boolean;
  617. pac_file_content?: string;
  618. enable_random_port?: boolean;
  619. verge_mixed_port?: number;
  620. verge_socks_port?: number;
  621. verge_redir_port?: number;
  622. verge_tproxy_port?: number;
  623. verge_port?: number;
  624. verge_redir_enabled?: boolean;
  625. verge_tproxy_enabled?: boolean;
  626. verge_socks_enabled?: boolean;
  627. verge_http_enabled?: boolean;
  628. enable_proxy_guard?: boolean;
  629. use_default_bypass?: boolean;
  630. proxy_guard_duration?: number;
  631. system_proxy_bypass?: string;
  632. web_ui_list?: string[];
  633. hotkeys?: string[];
  634. theme_setting?: {
  635. primary_color?: string;
  636. secondary_color?: string;
  637. primary_text?: string;
  638. secondary_text?: string;
  639. info_color?: string;
  640. error_color?: string;
  641. warning_color?: string;
  642. success_color?: string;
  643. font_family?: string;
  644. css_injection?: string;
  645. };
  646. auto_close_connection?: boolean;
  647. auto_check_update?: boolean;
  648. default_latency_test?: string;
  649. default_latency_timeout?: number;
  650. enable_builtin_enhanced?: boolean;
  651. auto_log_clean?: 0 | 1 | 2 | 3;
  652. proxy_layout_column?: number;
  653. test_list?: IVergeTestItem[];
  654. }