types.d.ts 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. /**
  2. * Some interface for clash api
  3. */
  4. declare namespace ApiType {
  5. interface ConfigData {
  6. port: number;
  7. mode: string;
  8. ipv6: boolean;
  9. "socket-port": number;
  10. "allow-lan": boolean;
  11. "log-level": string;
  12. "mixed-port": number;
  13. "redir-port": number;
  14. "socks-port": number;
  15. "tproxy-port": number;
  16. }
  17. interface RuleItem {
  18. type: string;
  19. payload: string;
  20. proxy: string;
  21. }
  22. interface ProxyItem {
  23. name: string;
  24. type: string;
  25. udp: boolean;
  26. history: {
  27. time: string;
  28. delay: number;
  29. }[];
  30. all?: string[];
  31. now?: string;
  32. provider?: string; // 记录是否来自provider
  33. }
  34. type ProxyGroupItem = Omit<ProxyItem, "all"> & {
  35. all: ProxyItem[];
  36. };
  37. interface ProviderItem {
  38. name: string;
  39. type: string;
  40. proxies: ProxyItem[];
  41. updatedAt: string;
  42. vehicleType: string;
  43. }
  44. interface TrafficItem {
  45. up: number;
  46. down: number;
  47. }
  48. interface LogItem {
  49. type: string;
  50. time?: string;
  51. payload: string;
  52. }
  53. interface ConnectionsItem {
  54. id: string;
  55. metadata: {
  56. network: string;
  57. type: string;
  58. host: string;
  59. sourceIP: string;
  60. sourcePort: string;
  61. destinationPort: string;
  62. destinationIP?: string;
  63. };
  64. upload: number;
  65. download: number;
  66. start: string;
  67. chains: string[];
  68. rule: string;
  69. rulePayload: string;
  70. curUpload?: number; // calculate
  71. curDownload?: number; // calculate
  72. }
  73. interface Connections {
  74. downloadTotal: number;
  75. uploadTotal: number;
  76. connections: ConnectionsItem[];
  77. }
  78. }
  79. /**
  80. * Some interface for command
  81. */
  82. declare namespace CmdType {
  83. type ProfileType = "local" | "remote" | "merge" | "script";
  84. interface ClashInfo {
  85. status: string;
  86. port?: string;
  87. server?: string;
  88. secret?: string;
  89. }
  90. interface ProfileItem {
  91. uid: string;
  92. type?: ProfileType | string;
  93. name?: string;
  94. desc?: string;
  95. file?: string;
  96. url?: string;
  97. updated?: number;
  98. selected?: {
  99. name?: string;
  100. now?: string;
  101. }[];
  102. extra?: {
  103. upload: number;
  104. download: number;
  105. total: number;
  106. expire: number;
  107. };
  108. option?: ProfileOption;
  109. }
  110. interface ProfileOption {
  111. user_agent?: string;
  112. with_proxy?: boolean;
  113. update_interval?: number;
  114. }
  115. interface ProfilesConfig {
  116. current?: string;
  117. chain?: string[];
  118. valid?: string[];
  119. items?: ProfileItem[];
  120. }
  121. interface VergeConfig {
  122. language?: string;
  123. clash_core?: string;
  124. theme_mode?: "light" | "dark" | "system";
  125. theme_blur?: boolean;
  126. traffic_graph?: boolean;
  127. enable_tun_mode?: boolean;
  128. enable_auto_launch?: boolean;
  129. enable_service_mode?: boolean;
  130. enable_silent_start?: boolean;
  131. enable_system_proxy?: boolean;
  132. enable_proxy_guard?: boolean;
  133. proxy_guard_duration?: number;
  134. system_proxy_bypass?: string;
  135. web_ui_list?: string[];
  136. hotkeys?: string[];
  137. theme_setting?: {
  138. primary_color?: string;
  139. secondary_color?: string;
  140. primary_text?: string;
  141. secondary_text?: string;
  142. info_color?: string;
  143. error_color?: string;
  144. warning_color?: string;
  145. success_color?: string;
  146. font_family?: string;
  147. css_injection?: string;
  148. };
  149. }
  150. type ClashConfigValue = any;
  151. interface ProfileMerge {
  152. // clash config fields (default supports)
  153. rules?: ClashConfigValue;
  154. proxies?: ClashConfigValue;
  155. "proxy-groups"?: ClashConfigValue;
  156. "proxy-providers"?: ClashConfigValue;
  157. "rule-providers"?: ClashConfigValue;
  158. // clash config fields (use flag)
  159. tun?: ClashConfigValue;
  160. dns?: ClashConfigValue;
  161. hosts?: ClashConfigValue;
  162. script?: ClashConfigValue;
  163. profile?: ClashConfigValue;
  164. payload?: ClashConfigValue;
  165. "interface-name"?: ClashConfigValue;
  166. "routing-mark"?: ClashConfigValue;
  167. // functional fields
  168. use?: string[];
  169. "prepend-rules"?: any[];
  170. "append-rules"?: any[];
  171. "prepend-proxies"?: any[];
  172. "append-proxies"?: any[];
  173. "prepend-proxy-groups"?: any[];
  174. "append-proxy-groups"?: any[];
  175. // fix
  176. ebpf?: any;
  177. experimental?: any;
  178. iptables?: any;
  179. sniffer?: any;
  180. authentication?: any;
  181. "bind-address"?: any;
  182. "external-ui"?: any;
  183. "auto-redir"?: any;
  184. "socks-port"?: any;
  185. "redir-port"?: any;
  186. "tproxy-port"?: any;
  187. "geodata-mode"?: any;
  188. "tcp-concurrent"?: any;
  189. }
  190. // partial of the clash config
  191. type ProfileData = Partial<{
  192. rules: any[];
  193. proxies: any[];
  194. "proxy-groups": any[];
  195. "proxy-providers": any[];
  196. "rule-providers": any[];
  197. [k: string]: any;
  198. }>;
  199. interface ChainItem {
  200. item: ProfileItem;
  201. merge?: ProfileMerge;
  202. script?: string;
  203. }
  204. interface EnhancedPayload {
  205. chain: ChainItem[];
  206. valid: string[];
  207. current: ProfileData;
  208. callback: string;
  209. }
  210. interface EnhancedResult {
  211. data: ProfileData;
  212. status: string;
  213. error?: string;
  214. }
  215. }