types.d.ts 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. }
  167. interface IProfilesConfig {
  168. current?: string;
  169. chain?: string[];
  170. valid?: string[];
  171. items?: IProfileItem[];
  172. }
  173. interface IVergeTestItem {
  174. uid: string;
  175. name?: string;
  176. icon?: string;
  177. url: string;
  178. }
  179. interface IVergeConfig {
  180. app_log_level?: "trace" | "debug" | "info" | "warn" | "error" | string;
  181. language?: string;
  182. tray_event?: "main_window" | "system_proxy" | "tun_mode" | string;
  183. env_type?: "bash" | "cmd" | "powershell" | string;
  184. startup_script?: string;
  185. start_page?: string;
  186. clash_core?: string;
  187. theme_mode?: "light" | "dark" | "system";
  188. traffic_graph?: boolean;
  189. enable_memory_usage?: boolean;
  190. enable_group_icon?: boolean;
  191. menu_icon?: "monochrome" | "colorful" | "disable";
  192. common_tray_icon?: boolean;
  193. sysproxy_tray_icon?: boolean;
  194. tun_tray_icon?: boolean;
  195. enable_tun_mode?: boolean;
  196. enable_auto_launch?: boolean;
  197. enable_service_mode?: boolean;
  198. enable_silent_start?: boolean;
  199. enable_system_proxy?: boolean;
  200. enable_random_port?: boolean;
  201. verge_mixed_port?: number;
  202. verge_socks_port?: number;
  203. verge_redir_port?: number;
  204. verge_tproxy_port?: number;
  205. verge_port?: number;
  206. enable_proxy_guard?: boolean;
  207. proxy_guard_duration?: number;
  208. system_proxy_bypass?: string;
  209. web_ui_list?: string[];
  210. hotkeys?: string[];
  211. theme_setting?: {
  212. primary_color?: string;
  213. secondary_color?: string;
  214. primary_text?: string;
  215. secondary_text?: string;
  216. info_color?: string;
  217. error_color?: string;
  218. warning_color?: string;
  219. success_color?: string;
  220. font_family?: string;
  221. css_injection?: string;
  222. };
  223. auto_close_connection?: boolean;
  224. auto_check_update?: boolean;
  225. default_latency_test?: string;
  226. default_latency_timeout?: number;
  227. enable_builtin_enhanced?: boolean;
  228. auto_log_clean?: 0 | 1 | 2 | 3;
  229. proxy_layout_column?: number;
  230. test_list?: IVergeTestItem[];
  231. }
  232. type IClashConfigValue = any;
  233. interface IProfileMerge {
  234. // clash config fields (default supports)
  235. rules?: IClashConfigValue;
  236. proxies?: IClashConfigValue;
  237. "proxy-groups"?: IClashConfigValue;
  238. "proxy-providers"?: IClashConfigValue;
  239. "rule-providers"?: IClashConfigValue;
  240. // clash config fields (use flag)
  241. tun?: IClashConfigValue;
  242. dns?: IClashConfigValue;
  243. hosts?: IClashConfigValue;
  244. script?: IClashConfigValue;
  245. profile?: IClashConfigValue;
  246. payload?: IClashConfigValue;
  247. "interface-name"?: IClashConfigValue;
  248. "routing-mark"?: IClashConfigValue;
  249. // functional fields
  250. use?: string[];
  251. "prepend-rules"?: any[];
  252. "append-rules"?: any[];
  253. "prepend-proxies"?: any[];
  254. "append-proxies"?: any[];
  255. "prepend-proxy-groups"?: any[];
  256. "append-proxy-groups"?: any[];
  257. // fix
  258. ebpf?: any;
  259. experimental?: any;
  260. iptables?: any;
  261. sniffer?: any;
  262. authentication?: any;
  263. "bind-address"?: any;
  264. "external-ui"?: any;
  265. "auto-redir"?: any;
  266. "socks-port"?: any;
  267. "redir-port"?: any;
  268. "tproxy-port"?: any;
  269. "geodata-mode"?: any;
  270. "tcp-concurrent"?: any;
  271. }
  272. // partial of the clash config
  273. type IProfileData = Partial<{
  274. rules: any[];
  275. proxies: any[];
  276. "proxy-groups": any[];
  277. "proxy-providers": any[];
  278. "rule-providers": any[];
  279. [k: string]: any;
  280. }>;
  281. interface IChainItem {
  282. item: IProfileItem;
  283. merge?: IProfileMerge;
  284. script?: string;
  285. }
  286. interface IEnhancedPayload {
  287. chain: IChainItem[];
  288. valid: string[];
  289. current: IProfileData;
  290. callback: string;
  291. }
  292. interface IEnhancedResult {
  293. data: IProfileData;
  294. status: string;
  295. error?: string;
  296. }