types.d.ts 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718
  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. type CipherType =
  241. | "none"
  242. | "auto"
  243. | "dummy"
  244. | "aes-128-gcm"
  245. | "aes-192-gcm"
  246. | "aes-256-gcm"
  247. | "lea-128-gcm"
  248. | "lea-192-gcm"
  249. | "lea-256-gcm"
  250. | "aes-128-gcm-siv"
  251. | "aes-256-gcm-siv"
  252. | "2022-blake3-aes-128-gcm"
  253. | "2022-blake3-aes-256-gcm"
  254. | "aes-128-cfb"
  255. | "aes-192-cfb"
  256. | "aes-256-cfb"
  257. | "aes-128-ctr"
  258. | "aes-192-ctr"
  259. | "aes-256-ctr"
  260. | "chacha20"
  261. | "chacha20-ietf"
  262. | "chacha20-ietf-poly1305"
  263. | "2022-blake3-chacha20-poly1305"
  264. | "rabbit128-poly1305"
  265. | "xchacha20-ietf-poly1305"
  266. | "xchacha20"
  267. | "aegis-128l"
  268. | "aegis-256"
  269. | "aez-384"
  270. | "deoxys-ii-256-128"
  271. | "rc4-md5";
  272. // base
  273. interface IProxyBaseConfig {
  274. tfo?: boolean;
  275. mptcp?: boolean;
  276. "interface-name"?: string;
  277. "routing-mark"?: number;
  278. "ip-version"?: "dual" | "ipv4" | "ipv6" | "ipv4-prefer" | "ipv6-prefer";
  279. "dialer-proxy"?: string;
  280. }
  281. // direct
  282. interface IProxyDirectConfig extends IProxyBaseConfig {
  283. name: string;
  284. type: "direct";
  285. }
  286. // dns
  287. interface IProxyDnsConfig extends IProxyBaseConfig {
  288. name: string;
  289. type: "dns";
  290. }
  291. // http
  292. interface IProxyHttpConfig extends IProxyBaseConfig {
  293. name: string;
  294. type: "http";
  295. server?: string;
  296. port?: number;
  297. username?: string;
  298. password?: string;
  299. tls?: boolean;
  300. sni?: string;
  301. "skip-cert-verify"?: boolean;
  302. fingerprint?: string;
  303. headers?: {
  304. [key: string]: string;
  305. };
  306. }
  307. // socks5
  308. interface IProxySocks5Config extends IProxyBaseConfig {
  309. name: string;
  310. type: "socks5";
  311. server?: string;
  312. port?: number;
  313. username?: string;
  314. password?: string;
  315. tls?: boolean;
  316. udp?: boolean;
  317. "skip-cert-verify"?: boolean;
  318. fingerprint?: string;
  319. }
  320. // ssh
  321. interface IProxySshConfig extends IProxyBaseConfig {
  322. name: string;
  323. type: "ssh";
  324. server?: string;
  325. port?: number;
  326. username?: string;
  327. password?: string;
  328. "private-key"?: string;
  329. "private-key-passphrase"?: string;
  330. "host-key"?: string;
  331. "host-key-algorithms"?: string;
  332. }
  333. // trojan
  334. interface IProxyTrojanConfig extends IProxyBaseConfig {
  335. name: string;
  336. type: "trojan";
  337. server?: string;
  338. port?: number;
  339. password?: string;
  340. alpn?: string[];
  341. sni?: string;
  342. "skip-cert-verify"?: boolean;
  343. fingerprint?: string;
  344. udp?: boolean;
  345. network?: NetworkType;
  346. "reality-opts"?: RealityOptions;
  347. "grpc-opts"?: GrpcOptions;
  348. "ws-opts"?: WsOptions;
  349. "ss-opts"?: {
  350. enabled?: boolean;
  351. method?: string;
  352. password?: string;
  353. };
  354. "client-fingerprint"?: string;
  355. }
  356. // tuic
  357. interface IProxyTuicConfig extends IProxyBaseConfig {
  358. name: string;
  359. type: "tuic";
  360. server?: string;
  361. port?: number;
  362. token?: string;
  363. uuid?: string;
  364. password?: string;
  365. ip?: string;
  366. "heartbeat-interval"?: number;
  367. alpn?: string[];
  368. "reduce-rtt"?: boolean;
  369. "request-timeout"?: number;
  370. "udp-relay-mode"?: string;
  371. "congestion-controller"?: string;
  372. "disable-sni"?: boolean;
  373. "max-udp-relay-packet-size"?: number;
  374. "fast-open"?: boolean;
  375. "max-open-streams"?: number;
  376. cwnd?: number;
  377. "skip-cert-verify"?: boolean;
  378. fingerprint?: string;
  379. ca?: string;
  380. "ca-str"?: string;
  381. "recv-window-conn"?: number;
  382. "recv-window"?: number;
  383. "disable-mtu-discovery"?: boolean;
  384. "max-datagram-frame-size"?: number;
  385. sni?: string;
  386. "udp-over-stream"?: boolean;
  387. "udp-over-stream-version"?: number;
  388. }
  389. // vless
  390. interface IProxyVlessConfig extends IProxyBaseConfig {
  391. name: string;
  392. type: "vless";
  393. server?: string;
  394. port?: number;
  395. uuid?: string;
  396. flow?: string;
  397. tls?: boolean;
  398. alpn?: string[];
  399. udp?: boolean;
  400. "packet-addr"?: boolean;
  401. xudp?: boolean;
  402. "packet-encoding"?: string;
  403. network?: NetworkType;
  404. "reality-opts"?: RealityOptions;
  405. "http-opts"?: HttpOptions;
  406. "h2-opts"?: H2Options;
  407. "grpc-opts"?: GrpcOptions;
  408. "ws-opts"?: WsOptions;
  409. "ws-path"?: string;
  410. "ws-headers"?: {
  411. [key: string]: string;
  412. };
  413. "skip-cert-verify"?: boolean;
  414. fingerprint?: string;
  415. servername?: string;
  416. "client-fingerprint"?: string;
  417. }
  418. // vmess
  419. interface IProxyVmessConfig extends IProxyBaseConfig {
  420. name: string;
  421. type: "vmess";
  422. server?: string;
  423. port?: number;
  424. uuid?: string;
  425. alterId?: number;
  426. cipher?: CipherType;
  427. udp?: boolean;
  428. network?: NetworkType;
  429. tls?: boolean;
  430. alpn?: string[];
  431. "skip-cert-verify"?: boolean;
  432. fingerprint?: string;
  433. servername?: string;
  434. "reality-opts"?: RealityOptions;
  435. "http-opts"?: HttpOptions;
  436. "h2-opts"?: H2Options;
  437. "grpc-opts"?: GrpcOptions;
  438. "ws-opts"?: WsOptions;
  439. "packet-addr"?: boolean;
  440. xudp?: boolean;
  441. "packet-encoding"?: string;
  442. "global-padding"?: boolean;
  443. "authenticated-length"?: boolean;
  444. "client-fingerprint"?: string;
  445. }
  446. interface WireGuardPeerOptions {
  447. server?: string;
  448. port?: number;
  449. "public-key"?: string;
  450. "pre-shared-key"?: string;
  451. reserved?: number[];
  452. "allowed-ips"?: string[];
  453. }
  454. // wireguard
  455. interface IProxyWireguardConfig extends IProxyBaseConfig, WireGuardPeerOptions {
  456. name: string;
  457. type: "wireguard";
  458. ip?: string;
  459. ipv6?: string;
  460. "private-key"?: string;
  461. workers?: number;
  462. mtu?: number;
  463. udp?: boolean;
  464. "persistent-keepalive"?: number;
  465. peers?: WireGuardPeerOptions[];
  466. "remote-dns-resolve"?: boolean;
  467. dns?: string[];
  468. "refresh-server-ip-interval"?: number;
  469. }
  470. // hysteria
  471. interface IProxyHysteriaConfig extends IProxyBaseConfig {
  472. name: string;
  473. type: "hysteria";
  474. server?: string;
  475. port?: number;
  476. ports?: string;
  477. protocol?: string;
  478. "obfs-protocol"?: string;
  479. up?: string;
  480. "up-speed"?: number;
  481. down?: string;
  482. "down-speed"?: number;
  483. auth?: string;
  484. "auth-str"?: string;
  485. obfs?: string;
  486. sni?: string;
  487. "skip-cert-verify"?: boolean;
  488. fingerprint?: string;
  489. alpn?: string[];
  490. ca?: string;
  491. "ca-str"?: string;
  492. "recv-window-conn"?: number;
  493. "recv-window"?: number;
  494. "disable-mtu-discovery"?: boolean;
  495. "fast-open"?: boolean;
  496. "hop-interval"?: number;
  497. }
  498. // hysteria2
  499. interface IProxyHysteria2Config extends IProxyBaseConfig {
  500. name: string;
  501. type: "hysteria2";
  502. server?: string;
  503. port?: number;
  504. ports?: string;
  505. "hop-interval"?: number;
  506. protocol?: string;
  507. "obfs-protocol"?: string;
  508. up?: string;
  509. down?: string;
  510. password?: string;
  511. obfs?: string;
  512. "obfs-password"?: string;
  513. sni?: string;
  514. "skip-cert-verify"?: boolean;
  515. fingerprint?: string;
  516. alpn?: string[];
  517. ca?: string;
  518. "ca-str"?: string;
  519. cwnd?: number;
  520. "udp-mtu"?: number;
  521. }
  522. // shadowsocks
  523. interface IProxyShadowsocksConfig extends IProxyBaseConfig {
  524. name: string;
  525. type: "ss";
  526. server?: string;
  527. port?: number;
  528. password?: string;
  529. cipher?: CipherType;
  530. udp?: boolean;
  531. plugin?: "obfs" | "v2ray-plugin" | "shadow-tls" | "restls";
  532. "plugin-opts"?: {
  533. mode?: string;
  534. host?: string;
  535. password?: string;
  536. path?: string;
  537. tls?: string;
  538. fingerprint?: string;
  539. headers?: {
  540. [key: string]: string;
  541. };
  542. "skip-cert-verify"?: boolean;
  543. version?: number;
  544. mux?: boolean;
  545. "v2ray-http-upgrade"?: boolean;
  546. "v2ray-http-upgrade-fast-open"?: boolean;
  547. "version-hint"?: string;
  548. "restls-script"?: string;
  549. };
  550. "udp-over-tcp"?: boolean;
  551. "udp-over-tcp-version"?: number;
  552. "client-fingerprint"?: string;
  553. }
  554. // shadowsocksR
  555. interface IProxyshadowsocksRConfig extends IProxyBaseConfig {
  556. name: string;
  557. type: "ssr";
  558. server?: string;
  559. port?: number;
  560. password?: string;
  561. cipher?: CipherType;
  562. obfs?: string;
  563. "obfs-param"?: string;
  564. protocol?: string;
  565. "protocol-param"?: string;
  566. udp?: boolean;
  567. }
  568. // sing-mux
  569. interface IProxySmuxConfig {
  570. smux?: {
  571. enabled?: boolean;
  572. protocol?: "smux" | "yamux" | "h2mux";
  573. "max-connections"?: number;
  574. "min-streams"?: number;
  575. "max-streams"?: number;
  576. padding?: boolean;
  577. statistic?: boolean;
  578. "only-tcp"?: boolean;
  579. "brutal-opts"?: {
  580. enabled?: boolean;
  581. up?: string;
  582. down?: string;
  583. };
  584. };
  585. }
  586. // snell
  587. interface IProxySnellConfig extends IProxyBaseConfig {
  588. name: string;
  589. type: "snell";
  590. server?: string;
  591. port?: number;
  592. psk?: string;
  593. udp?: boolean;
  594. version?: number;
  595. "obfs-opts"?: {};
  596. }
  597. interface IProxyConfig
  598. extends IProxyBaseConfig,
  599. IProxyDirectConfig,
  600. IProxyDnsConfig,
  601. IProxyHttpConfig,
  602. IProxySocks5Config,
  603. IProxySshConfig,
  604. IProxyTrojanConfig,
  605. IProxyTuicConfig,
  606. IProxyVlessConfig,
  607. IProxyVmessConfig,
  608. IProxyWireguardConfig,
  609. IProxyHysteriaConfig,
  610. IProxyHysteria2Config,
  611. IProxyShadowsocksConfig,
  612. IProxyshadowsocksRConfig,
  613. IProxySmuxConfig,
  614. IProxySnellConfig {
  615. type:
  616. | "ss"
  617. | "ssr"
  618. | "direct"
  619. | "dns"
  620. | "snell"
  621. | "http"
  622. | "trojan"
  623. | "hysteria"
  624. | "hysteria2"
  625. | "tuic"
  626. | "wireguard"
  627. | "ssh"
  628. | "socks5"
  629. | "vmess"
  630. | "vless";
  631. }
  632. interface IVergeConfig {
  633. app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string;
  634. language?: string;
  635. tray_event?: "main_window" | "system_proxy" | "tun_mode" | string;
  636. env_type?: "bash" | "cmd" | "powershell" | string;
  637. startup_script?: string;
  638. start_page?: string;
  639. clash_core?: string;
  640. theme_mode?: "light" | "dark" | "system";
  641. traffic_graph?: boolean;
  642. enable_memory_usage?: boolean;
  643. enable_group_icon?: boolean;
  644. menu_icon?: "monochrome" | "colorful" | "disable";
  645. tray_icon?: "monochrome" | "colorful";
  646. common_tray_icon?: boolean;
  647. sysproxy_tray_icon?: boolean;
  648. tun_tray_icon?: boolean;
  649. enable_tun_mode?: boolean;
  650. enable_auto_launch?: boolean;
  651. enable_service_mode?: boolean;
  652. enable_silent_start?: boolean;
  653. enable_system_proxy?: boolean;
  654. proxy_auto_config?: boolean;
  655. pac_file_content?: string;
  656. enable_random_port?: boolean;
  657. verge_mixed_port?: number;
  658. verge_socks_port?: number;
  659. verge_redir_port?: number;
  660. verge_tproxy_port?: number;
  661. verge_port?: number;
  662. verge_redir_enabled?: boolean;
  663. verge_tproxy_enabled?: boolean;
  664. verge_socks_enabled?: boolean;
  665. verge_http_enabled?: boolean;
  666. enable_proxy_guard?: boolean;
  667. use_default_bypass?: boolean;
  668. proxy_guard_duration?: number;
  669. system_proxy_bypass?: string;
  670. web_ui_list?: string[];
  671. hotkeys?: string[];
  672. theme_setting?: {
  673. primary_color?: string;
  674. secondary_color?: string;
  675. primary_text?: string;
  676. secondary_text?: string;
  677. info_color?: string;
  678. error_color?: string;
  679. warning_color?: string;
  680. success_color?: string;
  681. font_family?: string;
  682. css_injection?: string;
  683. };
  684. auto_close_connection?: boolean;
  685. auto_check_update?: boolean;
  686. default_latency_test?: string;
  687. default_latency_timeout?: number;
  688. enable_builtin_enhanced?: boolean;
  689. auto_log_clean?: 0 | 1 | 2 | 3;
  690. proxy_layout_column?: number;
  691. test_list?: IVergeTestItem[];
  692. }