x3ui-api 1.0.3 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
- import {AxiosInstance} from 'axios';
1
+ import X3UIClient from "./core/X3UIClient";
2
+
3
+ export default X3UIClient;
2
4
 
3
5
  export interface X3UIConfig {
4
6
  baseURL: string;
@@ -48,8 +50,16 @@ export interface StreamSettings {
48
50
  network: string;
49
51
  security: string;
50
52
  externalProxy: any[];
51
- realitySettings: RealitySettings;
53
+ realitySettings?: RealitySettings;
52
54
  tcpSettings?: TCPSettings;
55
+ httpupgradeSettings?: HttpUpgradeSettings;
56
+ }
57
+
58
+ export interface HttpUpgradeSettings {
59
+ acceptProxyProtocol: boolean;
60
+ path: string;
61
+ host: string;
62
+ headers: Record<string, string>;
53
63
  }
54
64
 
55
65
  export interface TCPSettings {
@@ -153,19 +163,6 @@ export interface SystemStats {
153
163
  }
154
164
  }
155
165
 
156
- export interface RealityInboundOptions {
157
- remark: string;
158
- port?: number;
159
- dest?: string;
160
- serverNames?: string[];
161
- privateKey?: string;
162
- publicKey?: string;
163
- shortIds?: string[];
164
- fingerprint?: string;
165
- listenIP?: string;
166
- expiryTime?: number;
167
- }
168
-
169
166
  export interface ClientOptions {
170
167
  id?: string;
171
168
  email?: string;
@@ -173,136 +170,3 @@ export interface ClientOptions {
173
170
  expiryTime?: number;
174
171
  tgId?: string;
175
172
  }
176
-
177
- export interface ClientBuilder {
178
- /**
179
- * Set client UUID. If not provided, will be auto-generated
180
- */
181
- setId(id: string): this;
182
-
183
- /**
184
- * Set client email
185
- */
186
- setEmail(email: string): this;
187
-
188
- /**
189
- * Set total traffic limit in GB
190
- */
191
- setTotalGB(gb: number): this;
192
-
193
- /**
194
- * Set expiry time in unix timestamp
195
- */
196
- setExpiryTime(timestamp: number): this;
197
-
198
- /**
199
- * Set Telegram ID
200
- */
201
- setTgId(id: string): this;
202
-
203
- /**
204
- * Build the client configuration
205
- */
206
- build(): ClientSettings;
207
-
208
- /**
209
- * Generate connection link for this client
210
- * @param host Host address
211
- * @param port Optional port number, defaults to parent's port
212
- * @param protocol Optional protocol, defaults to parent's protocol or 'vless'
213
- */
214
- getLink(host: string, port?: number, protocol?: string): string;
215
- }
216
-
217
- export interface RealityBuilder {
218
- /**
219
- * Set the port for the inbound. If not provided, will auto-generate unused port
220
- */
221
- setPort(port: number): this;
222
-
223
- /**
224
- * Set the remark/name for the inbound
225
- */
226
- setRemark(remark: string): this;
227
-
228
- /**
229
- * Set the destination address (e.g. "yahoo.com:443")
230
- */
231
- setDest(dest: string): this;
232
-
233
- /**
234
- * Set server names for SNI
235
- */
236
- setServerNames(names: string[]): this;
237
-
238
- /**
239
- * Set Reality keypair. If not provided, will be auto-generated
240
- */
241
- setKeyPair(privateKey: string, publicKey: string): this;
242
-
243
- /**
244
- * Set short IDs for Reality. If not provided, random ones will be generated
245
- */
246
- setShortIds(ids: string[]): this;
247
-
248
- /**
249
- * Set browser fingerprint. Defaults to "chrome"
250
- */
251
- setFingerprint(fingerprint: string): this;
252
-
253
- /**
254
- * Set listen IP address. Defaults to empty string
255
- */
256
- setListenIP(ip: string): this;
257
-
258
- /**
259
- * Set inbound expiry time. Defaults to 0 (no expiry)
260
- */
261
- setExpiryTime(timestamp: number): this;
262
-
263
- /**
264
- * Add a new client to the inbound
265
- */
266
- addClient(options?: Partial<ClientSettings>): ClientBuilder;
267
-
268
- /**
269
- * Get connection link for a client
270
- * @param clientIndex Index of the client (defaults to 0)
271
- * @param host Optional host address (defaults to listenIP or 'localhost')
272
- */
273
- getClientLink(clientIndex?: number, host?: string): string;
274
-
275
- /**
276
- * Build the final inbound config
277
- */
278
- build(): Promise<InboundConfig>;
279
- }
280
-
281
- export default class X3UIClient {
282
- private client: AxiosInstance;
283
-
284
- constructor(config: X3UIConfig);
285
-
286
- login(username: string, password: string): Promise<LoginResponse>;
287
-
288
- getSystemStats(): Promise<SystemStats>;
289
-
290
- getInbounds(): Promise<InboundConfig[]>;
291
-
292
- addInbound(config: Omit<InboundConfig, 'id'>): Promise<InboundConfig>;
293
-
294
- updateInbound(id: number, config: Partial<InboundConfig>): Promise<void>;
295
-
296
- deleteInbound(id: number): Promise<void>;
297
-
298
- getInboundTraffic(id: number): Promise<{ up: number; down: number }>;
299
-
300
- resetInboundTraffic(id: number): Promise<void>;
301
-
302
- getNewX25519Cert(): Promise<{ privateKey: string; publicKey: string }>;
303
-
304
- /**
305
- * Create a new Reality inbound builder
306
- */
307
- createRealityBuilder(options?: Partial<InboundConfig>): RealityBuilder;
308
- }
@@ -0,0 +1,185 @@
1
+ import X3UIClient from "./core/X3UIClient";
2
+
3
+ export default X3UIClient;
4
+
5
+ export interface X3UIConfig {
6
+ baseURL: string;
7
+ token?: string;
8
+ parseJSONSettings?: boolean;
9
+ }
10
+
11
+ export interface LoginResponse {
12
+ success: boolean;
13
+ msg: string;
14
+ obj: any;
15
+ }
16
+
17
+ export interface InboundConfig {
18
+ id?: number;
19
+ up: number;
20
+ down: number;
21
+ total: number;
22
+ remark: string;
23
+ enable: boolean;
24
+ expiryTime: number | null;
25
+ clientStats: ClientStats[];
26
+ listen: string;
27
+ port: number;
28
+ protocol: string;
29
+ settings: string | InboundSettings;
30
+ streamSettings: string | StreamSettings;
31
+ tag: string;
32
+ sniffing: string | SniffingSettings;
33
+ allocate: string | AllocateSettings;
34
+ }
35
+
36
+ export interface AllocateSettings {
37
+ strategy: string;
38
+ refresh: number;
39
+ concurrency: number;
40
+ }
41
+
42
+ export interface SniffingSettings {
43
+ enabled: boolean;
44
+ destOverride: string[];
45
+ metadataOnly: boolean;
46
+ routeOnly: boolean;
47
+ }
48
+
49
+ export interface StreamSettings {
50
+ network: string;
51
+ security: string;
52
+ externalProxy: any[];
53
+ realitySettings?: RealitySettings;
54
+ tcpSettings?: TCPSettings;
55
+ httpupgradeSettings?: HttpUpgradeSettings;
56
+ }
57
+
58
+ export interface HttpUpgradeSettings {
59
+ acceptProxyProtocol: boolean;
60
+ path: string;
61
+ host: string;
62
+ headers: Record<string, string>;
63
+ }
64
+
65
+ export interface TCPSettings {
66
+ acceptProxyProtocol: boolean;
67
+ header: {
68
+ type: string;
69
+ }
70
+ }
71
+
72
+ export interface RealitySettings {
73
+ show: boolean;
74
+ xver: number;
75
+ dest: string;
76
+ serverNames: string[];
77
+ privateKey: string;
78
+ minClient: string;
79
+ maxClient: string;
80
+ maxTimediff: number;
81
+ shortIds: string[];
82
+ settings: {
83
+ publicKey: string;
84
+ fingerprint: string;
85
+ serverName: string;
86
+ spiderX: string;
87
+ }
88
+ }
89
+
90
+ export interface InboundSettings {
91
+ clients: ClientSettings[];
92
+ decryption: string;
93
+ fallbacks: any[];
94
+ }
95
+
96
+ export interface ClientSettings {
97
+ id: string;
98
+ flow: string;
99
+ email: string;
100
+ limitIp: number;
101
+ totalGB: number;
102
+ expiryTime: number | null;
103
+ enable: boolean;
104
+ tgId: string;
105
+ subId: string;
106
+ reset: number;
107
+ }
108
+
109
+ export interface ClientStats {
110
+ id: number;
111
+ inboundId: number;
112
+ enable: boolean;
113
+ email: string;
114
+ up: number;
115
+ down: number;
116
+ expiryTime: number | null;
117
+ total: number;
118
+ reset: number;
119
+ }
120
+
121
+ export interface SystemStats {
122
+ cpu: number;
123
+ cpuCores: number;
124
+ logicalPro: number;
125
+ cpuSpeedMhz: number;
126
+ mem: {
127
+ current: number;
128
+ total: number;
129
+ };
130
+ swap: {
131
+ current: number;
132
+ total: number;
133
+ }
134
+ disk: {
135
+ current: number;
136
+ total: number;
137
+ };
138
+ xray: {
139
+ state: boolean;
140
+ errorMsg: string;
141
+ version: string;
142
+ };
143
+ uptime: number;
144
+ loads: number[];
145
+ tcpCount: number;
146
+ udpCount: number;
147
+ netIO: {
148
+ up: number;
149
+ down: number;
150
+ };
151
+ netTraffic: {
152
+ up: number;
153
+ down: number;
154
+ };
155
+ publicIP: {
156
+ ipv4: string;
157
+ ipv6: string;
158
+ }
159
+ appStats: {
160
+ threads: number;
161
+ mem: number;
162
+ uptime: number;
163
+ }
164
+ }
165
+
166
+ export interface RealityInboundOptions {
167
+ remark: string;
168
+ port?: number;
169
+ dest?: string;
170
+ serverNames?: string[];
171
+ privateKey?: string;
172
+ publicKey?: string;
173
+ shortIds?: string[];
174
+ fingerprint?: string;
175
+ listenIP?: string;
176
+ expiryTime?: number;
177
+ }
178
+
179
+ export interface ClientOptions {
180
+ id?: string;
181
+ email?: string;
182
+ totalGB?: number;
183
+ expiryTime?: number;
184
+ tgId?: string;
185
+ }