Skip to content

Commit 02998c5

Browse files
Added ip limit data and controls to client info modal (#2617)
1 parent 3f38c42 commit 02998c5

File tree

1 file changed

+59
-0
lines changed

1 file changed

+59
-0
lines changed

web/html/xui/inbound_info_modal.html

+59
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,25 @@
185185
<a-tag>↑ [[ sizeFormat(infoModal.clientStats.up) ]] / [[ sizeFormat(infoModal.clientStats.down) ]] ↓</a-tag>
186186
</td>
187187
</tr>
188+
<tr v-if="app.ipLimitEnable">
189+
<td>{{ i18n "pages.inbounds.IPLimit" }}</td>
190+
<td>
191+
<a-tag>[[ infoModal.clientSettings.limitIp ]]</a-tag>
192+
</td>
193+
</tr>
194+
<tr v-if="app.ipLimitEnable">
195+
<td>{{ i18n "pages.inbounds.IPLimitlog" }}</td>
196+
<td>
197+
<a-tag>[[ infoModal.clientIps ]]</a-tag>
198+
<a-icon type="sync" :spin="refreshing" @click="refreshIPs" style="margin: 0 5px;"></a-icon>
199+
<a-tooltip :title="[[ dbInbound.address ]]">
200+
<template slot="title">
201+
<span>{{ i18n "pages.inbounds.IPLimitlogclear" }}</span>
202+
</template>
203+
<a-icon type="delete" @click="clearClientIps"></a-icon>
204+
</a-tooltip>
205+
</td>
206+
</tr>
188207
</table>
189208
<table style="display: inline-table; margin-block: 10px; width: 100%; text-align: center;">
190209
<tr>
@@ -417,6 +436,18 @@
417436
</template>
418437
</a-modal>
419438
<script>
439+
function refreshIPs(email) {
440+
return HttpUtil.post(`/panel/inbound/clientIps/${email}`).then((msg) => {
441+
if (msg.success) {
442+
try {
443+
return JSON.parse(msg.obj).join(', ');
444+
} catch (e) {
445+
return msg.obj;
446+
}
447+
}
448+
});
449+
}
450+
420451
const infoModal = {
421452
visible: false,
422453
inbound: new Inbound(),
@@ -431,13 +462,20 @@
431462
isExpired: false,
432463
subLink: '',
433464
subJsonLink: '',
465+
clientIps: '',
434466
show(dbInbound, index) {
435467
this.index = index;
436468
this.inbound = dbInbound.toInbound();
437469
this.dbInbound = new DBInbound(dbInbound);
438470
this.clientSettings = this.inbound.clients ? this.inbound.clients[index] : null;
439471
this.isExpired = this.inbound.clients ? this.inbound.isExpiry(index) : this.dbInbound.isExpiry;
440472
this.clientStats = this.inbound.clients ? this.dbInbound.clientStats.find(row => row.email === this.clientSettings.email) : [];
473+
474+
if (app.ipLimitEnable && this.clientSettings.limitIp) {
475+
refreshIPs(this.clientStats.email).then((ips) => {
476+
this.clientIps = ips;
477+
})
478+
}
441479
if (this.inbound.protocol == Protocols.WIREGUARD) {
442480
this.links = this.inbound.genInboundLinks(dbInbound.remark).split('\r\n')
443481
} else {
@@ -466,6 +504,7 @@
466504
el: '#inbound-info-modal',
467505
data: {
468506
infoModal,
507+
refreshing: false,
469508
get dbInbound() {
470509
return this.infoModal.dbInbound;
471510
},
@@ -502,6 +541,26 @@
502541
remained = this.infoModal.clientStats.total - this.infoModal.clientStats.up - this.infoModal.clientStats.down;
503542
return remained > 0 ? sizeFormat(remained) : '-';
504543
},
544+
refreshIPs() {
545+
this.refreshing = true;
546+
refreshIPs(this.infoModal.clientStats.email)
547+
.then((ips) => {
548+
this.infoModal.clientIps = ips;
549+
})
550+
.finally(() => {
551+
this.refreshing = false;
552+
});
553+
},
554+
clearClientIps() {
555+
HttpUtil.post(`/panel/inbound/clearClientIps/${this.infoModal.clientStats.email}`)
556+
.then((msg) => {
557+
if (!msg.success) {
558+
return;
559+
}
560+
this.infoModal.clientIps = 'No IP Record';
561+
})
562+
.catch(() => {});
563+
},
505564
},
506565
});
507566
</script>

0 commit comments

Comments
 (0)