types.d.ts 16 KB

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