x3ui-api 1.0.8-1 → 1.0.9-1

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "x3ui-api",
3
- "version": "1.0.8-1",
3
+ "version": "1.0.9-1",
4
4
  "description": "API client for x3ui panel",
5
5
  "main": "src/index.js",
6
6
  "types": "src/index.d.ts",
@@ -65,6 +65,13 @@ export default class VmessBuilder {
65
65
  */
66
66
  getClientLink(clientIndex?: number, host?: string): string;
67
67
 
68
+ /**
69
+ * Get connection link for a client
70
+ * @param email Email of the client
71
+ * @param host Optional host address (defaults to listenIP or 'localhost')
72
+ */
73
+ getClientLinkByEmail(email: string, host?: string): string;
74
+
68
75
  /**
69
76
  * Generate a random port number
70
77
  */
@@ -130,6 +130,14 @@ module.exports = class VmessBuilder {
130
130
  return client.getLink(host || this.listenIP || 'localhost', port || this.port);
131
131
  }
132
132
 
133
+ getClientLinkByEmail(email, host) {
134
+ const client = this.clients.find(client => client.email === email);
135
+ if (!client) {
136
+ throw new Error('Client not found');
137
+ }
138
+ return client.getLink(host || this.listenIP || 'localhost', this.port);
139
+ }
140
+
133
141
  generateRandomPort() {
134
142
  return Math.floor(Math.random() * (65535 - 1024) + 1024);
135
143
  }
@@ -87,6 +87,13 @@ export default class WireguardBuilder {
87
87
  * @returns A formatted connection link string
88
88
  */
89
89
  getClientLink(clientIndex?: number, host?: string, port?: number): string;
90
+
91
+ /**
92
+ * Get connection link for a client
93
+ * @param email Email of the client
94
+ * @param host Optional host address (defaults to listenIP or 'localhost')
95
+ */
96
+ getClientLinkByEmail(email: string, host?: string): string;
90
97
 
91
98
  /**
92
99
  * Generates a configuration file for a client.
@@ -132,6 +132,14 @@ module.exports = class WireguardBuilder {
132
132
  return client.getLink(host || this.listenIP || 'localhost', port || this.port);
133
133
  }
134
134
 
135
+ getClientLinkByEmail(email, host) {
136
+ const client = this.clients.find(client => client.email === email);
137
+ if (!client) {
138
+ throw new Error('Client not found');
139
+ }
140
+ return client.getLink(host || this.listenIP || 'localhost', this.port);
141
+ }
142
+
135
143
  getClientConfig(clientIndex = 0, host, port) {
136
144
  if (clientIndex < 0 || clientIndex >= this.clients.length) {
137
145
  throw new Error('Invalid client index');