types.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. /**
  2. * Some interface for clash api
  3. */
  4. export namespace ApiType {
  5. export 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. export interface RuleItem {
  18. type: string;
  19. payload: string;
  20. proxy: string;
  21. }
  22. export 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. }
  33. export type ProxyGroupItem = Omit<ProxyItem, "all"> & {
  34. all: ProxyItem[];
  35. };
  36. export interface TrafficItem {
  37. up: number;
  38. down: number;
  39. }
  40. export interface LogItem {
  41. type: string;
  42. time?: string;
  43. payload: string;
  44. }
  45. export interface ConnectionsItem {
  46. id: string;
  47. metadata: {
  48. network: string;
  49. type: string;
  50. host: string;
  51. sourceIP: string;
  52. sourcePort: string;
  53. destinationPort: string;
  54. destinationIP?: string;
  55. };
  56. upload: number;
  57. download: number;
  58. start: string;
  59. chains: string[];
  60. rule: string;
  61. rulePayload: string;
  62. }
  63. export interface Connections {
  64. downloadTotal: number;
  65. uploadTotal: number;
  66. connections: ConnectionsItem[];
  67. }
  68. }
  69. /**
  70. * Some interface for command
  71. */
  72. export namespace CmdType {
  73. export type ProfileType = "local" | "remote" | "merge" | "script";
  74. export interface ClashInfo {
  75. status: string;
  76. port?: string;
  77. server?: string;
  78. secret?: string;
  79. }
  80. export interface ProfileItem {
  81. uid: string;
  82. type?: ProfileType | string;
  83. name?: string;
  84. desc?: string;
  85. file?: string;
  86. url?: string;
  87. updated?: number;
  88. selected?: {
  89. name?: string;
  90. now?: string;
  91. }[];
  92. extra?: {
  93. upload: number;
  94. download: number;
  95. total: number;
  96. expire: number;
  97. };
  98. option?: ProfileOption;
  99. }
  100. export interface ProfileOption {
  101. user_agent?: string;
  102. with_proxy?: boolean;
  103. }
  104. export interface ProfilesConfig {
  105. current?: string;
  106. chain?: string[];
  107. items?: ProfileItem[];
  108. }
  109. export interface VergeConfig {
  110. language?: string;
  111. theme_mode?: "light" | "dark";
  112. theme_blur?: boolean;
  113. traffic_graph?: boolean;
  114. enable_tun_mode?: boolean;
  115. enable_auto_launch?: boolean;
  116. enable_silent_start?: boolean;
  117. enable_system_proxy?: boolean;
  118. enable_proxy_guard?: boolean;
  119. system_proxy_bypass?: string;
  120. theme_setting?: {
  121. primary_color?: string;
  122. secondary_color?: string;
  123. primary_text?: string;
  124. secondary_text?: string;
  125. info_color?: string;
  126. error_color?: string;
  127. warning_color?: string;
  128. success_color?: string;
  129. font_face?: string;
  130. font_family?: string;
  131. };
  132. }
  133. type ClashConfigValue = any;
  134. export interface ProfileMerge {
  135. // clash config fields (default supports)
  136. rules?: ClashConfigValue;
  137. proxies?: ClashConfigValue;
  138. "proxy-groups"?: ClashConfigValue;
  139. "proxy-providers"?: ClashConfigValue;
  140. "rule-providers"?: ClashConfigValue;
  141. // clash config fields (use flag)
  142. tun?: ClashConfigValue;
  143. dns?: ClashConfigValue;
  144. hosts?: ClashConfigValue;
  145. script?: ClashConfigValue;
  146. profile?: ClashConfigValue;
  147. payload?: ClashConfigValue;
  148. "interface-name"?: ClashConfigValue;
  149. "routing-mark"?: ClashConfigValue;
  150. // functional fields
  151. use?: string[];
  152. "prepend-rules"?: any[];
  153. "append-rules"?: any[];
  154. "prepend-proxies"?: any[];
  155. "append-proxies"?: any[];
  156. "prepend-proxy-groups"?: any[];
  157. "append-proxy-groups"?: any[];
  158. }
  159. // partial of the clash config
  160. export type ProfileData = Partial<{
  161. rules: any[];
  162. proxies: any[];
  163. "proxy-groups": any[];
  164. "proxy-providers": any[];
  165. "rule-providers": any[];
  166. [k: string]: any;
  167. }>;
  168. export interface ChainItem {
  169. item: ProfileItem;
  170. merge?: ProfileMerge;
  171. script?: string;
  172. }
  173. export interface EnhancedPayload {
  174. chain: ChainItem[];
  175. current: ProfileData;
  176. callback: string;
  177. }
  178. export interface EnhancedResult {
  179. data: ProfileData;
  180. status: string;
  181. error?: string;
  182. }
  183. }