|
185 | 185 | <a-tag>↑ [[ sizeFormat(infoModal.clientStats.up) ]] / [[ sizeFormat(infoModal.clientStats.down) ]] ↓</a-tag>
|
186 | 186 | </td>
|
187 | 187 | </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> |
188 | 207 | </table>
|
189 | 208 | <table style="display: inline-table; margin-block: 10px; width: 100%; text-align: center;">
|
190 | 209 | <tr>
|
|
417 | 436 | </template>
|
418 | 437 | </a-modal>
|
419 | 438 | <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 | + |
420 | 451 | const infoModal = {
|
421 | 452 | visible: false,
|
422 | 453 | inbound: new Inbound(),
|
|
431 | 462 | isExpired: false,
|
432 | 463 | subLink: '',
|
433 | 464 | subJsonLink: '',
|
| 465 | + clientIps: '', |
434 | 466 | show(dbInbound, index) {
|
435 | 467 | this.index = index;
|
436 | 468 | this.inbound = dbInbound.toInbound();
|
437 | 469 | this.dbInbound = new DBInbound(dbInbound);
|
438 | 470 | this.clientSettings = this.inbound.clients ? this.inbound.clients[index] : null;
|
439 | 471 | this.isExpired = this.inbound.clients ? this.inbound.isExpiry(index) : this.dbInbound.isExpiry;
|
440 | 472 | 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 | + } |
441 | 479 | if (this.inbound.protocol == Protocols.WIREGUARD) {
|
442 | 480 | this.links = this.inbound.genInboundLinks(dbInbound.remark).split('\r\n')
|
443 | 481 | } else {
|
|
466 | 504 | el: '#inbound-info-modal',
|
467 | 505 | data: {
|
468 | 506 | infoModal,
|
| 507 | + refreshing: false, |
469 | 508 | get dbInbound() {
|
470 | 509 | return this.infoModal.dbInbound;
|
471 | 510 | },
|
|
502 | 541 | remained = this.infoModal.clientStats.total - this.infoModal.clientStats.up - this.infoModal.clientStats.down;
|
503 | 542 | return remained > 0 ? sizeFormat(remained) : '-';
|
504 | 543 | },
|
| 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 | + }, |
505 | 564 | },
|
506 | 565 | });
|
507 | 566 | </script>
|
|
0 commit comments