3x-ui/web/html/xui/inbounds.html

784 lines
40 KiB
HTML
Raw Normal View History

2023-02-09 22:18:06 +03:00
<!DOCTYPE html>
<html lang="en">
{{template "head" .}}
<style>
@media (min-width: 769px) {
.ant-layout-content {
margin: 24px 16px;
}
}
.ant-col-sm-24 {
margin-top: 10px;
}
</style>
<body>
<a-layout id="app" v-cloak>
{{ template "commonSider" . }}
2023-03-17 01:01:14 +03:00
<a-layout id="content-layout" :style="siderDrawer.isDarkTheme ? bgDarkStyle : ''">
2023-02-09 22:18:06 +03:00
<a-layout-content>
<a-spin :spinning="spinning" :delay="500" tip="loading">
<transition name="list" appear>
<a-tag v-if="false" color="red" style="margin-bottom: 10px">
Please go to the panel settings as soon as possible to modify the username and password, otherwise there may be a risk of leaking account information
</a-tag>
</transition>
<transition name="list" appear>
2023-03-17 01:01:14 +03:00
<a-card hoverable style="margin-bottom: 20px;" :class="siderDrawer.isDarkTheme ? darkClass : ''">
2023-02-09 22:18:06 +03:00
<a-row>
<a-col :xs="24" :sm="24" :lg="12">
2023-03-17 19:07:49 +03:00
{{ i18n "pages.inbounds.totalDownUp" }}:
2023-02-09 22:18:06 +03:00
<a-tag color="green">[[ sizeFormat(total.up) ]] / [[ sizeFormat(total.down) ]]</a-tag>
</a-col>
<a-col :xs="24" :sm="24" :lg="12">
2023-03-17 19:07:49 +03:00
{{ i18n "pages.inbounds.totalUsage" }}:
2023-02-09 22:18:06 +03:00
<a-tag color="green">[[ sizeFormat(total.up + total.down) ]]</a-tag>
</a-col>
<a-col :xs="24" :sm="24" :lg="12">
2023-03-17 19:07:49 +03:00
{{ i18n "pages.inbounds.inboundCount" }}:
2023-02-09 22:18:06 +03:00
<a-tag color="green">[[ dbInbounds.length ]]</a-tag>
</a-col>
2023-03-17 01:01:14 +03:00
<a-col :xs="24" :sm="24" :lg="12">
{{ i18n "clients" }}:
<a-tag color="green">[[ total.clients ]]</a-tag>
2023-04-24 15:34:01 +03:00
<a-popover title='{{ i18n "disabled" }}' :overlay-class-name="siderDrawer.isDarkTheme ? 'ant-dark' : ''">
<template slot="content">
<p v-for="clientEmail in total.deactive">[[ clientEmail ]]</p>
</template>
<a-tag v-if="total.deactive.length">[[ total.deactive.length ]]</a-tag>
</a-popover>
2023-04-24 15:34:01 +03:00
<a-popover title='{{ i18n "depleted" }}' :overlay-class-name="siderDrawer.isDarkTheme ? 'ant-dark' : ''">
<template slot="content">
<p v-for="clientEmail in total.depleted">[[ clientEmail ]]</p>
</template>
<a-tag color="red" v-if="total.depleted.length">[[ total.depleted.length ]]</a-tag>
</a-popover>
2023-04-24 15:34:01 +03:00
<a-popover title='{{ i18n "depletingSoon" }}' :overlay-class-name="siderDrawer.isDarkTheme ? 'ant-dark' : ''">
<template slot="content">
<p v-for="clientEmail in total.expiring">[[ clientEmail ]]</p>
</template>
<a-tag color="orange" v-if="total.expiring.length">[[ total.expiring.length ]]</a-tag>
</a-popover>
2023-03-17 01:01:14 +03:00
</a-col>
2023-02-09 22:18:06 +03:00
</a-row>
</a-card>
</transition>
<transition name="list" appear>
2023-03-17 01:01:14 +03:00
<a-card hoverable :class="siderDrawer.isDarkTheme ? darkClass : ''">
2023-02-09 22:18:06 +03:00
<div slot="title">
2023-03-17 19:07:49 +03:00
<a-button type="primary" icon="plus" @click="openAddInbound">{{ i18n "pages.inbounds.addInbound" }}</a-button>
<a-button type="primary" icon="export" @click="exportAllLinks">{{ i18n "pages.inbounds.export" }}</a-button>
<a-button type="primary" icon="reload" @click="resetAllTraffic">{{ i18n "pages.inbounds.resetAllTraffic" }}</a-button>
2023-02-09 22:18:06 +03:00
</div>
<a-input v-model.lazy="searchKey" placeholder='{{ i18n "search" }}' autofocus style="max-width: 300px"></a-input>
2023-02-09 22:18:06 +03:00
<a-table :columns="columns" :row-key="dbInbound => dbInbound.id"
2023-02-12 16:50:09 +03:00
:data-source="searchedInbounds"
:loading="spinning" :scroll="{ x: 1300 }"
2023-02-09 22:18:06 +03:00
:pagination="false"
style="margin-top: 20px"
@change="() => getDBInbounds()">
<template slot="action" slot-scope="text, dbInbound">
2023-02-18 18:55:53 +03:00
<a-icon type="edit" style="font-size: 25px" @click="openEditInbound(dbInbound.id);"></a-icon>
2023-02-09 22:18:06 +03:00
<a-dropdown :trigger="['click']">
<a @click="e => e.preventDefault()">{{ i18n "pages.inbounds.operate" }}</a>
<a-menu slot="overlay" @click="a => clickAction(a, dbInbound)" :theme="siderDrawer.theme">
2023-02-12 16:50:09 +03:00
<a-menu-item v-if="dbInbound.isSS" key="qrcode">
2023-02-09 22:18:06 +03:00
<a-icon type="qrcode"></a-icon>
{{ i18n "qrCode" }}
</a-menu-item>
<a-menu-item key="edit">
<a-icon type="edit"></a-icon>
{{ i18n "edit" }}
</a-menu-item>
2023-03-17 19:07:49 +03:00
<template v-if="dbInbound.isTrojan || dbInbound.isVLess || dbInbound.isVMess">
<a-menu-item key="addClient">
<a-icon type="user-add"></a-icon>
2023-03-17 19:07:49 +03:00
{{ i18n "pages.client.add"}}
</a-menu-item>
<a-menu-item key="addBulkClient">
<a-icon type="usergroup-add"></a-icon>
2023-03-17 19:07:49 +03:00
{{ i18n "pages.client.bulk"}}
</a-menu-item>
<a-menu-item key="resetClients">
<a-icon type="file-done"></a-icon>
{{ i18n "pages.inbounds.resetAllClientTraffics"}}
</a-menu-item>
2023-03-17 01:01:14 +03:00
<a-menu-item key="export">
<a-icon type="export"></a-icon>
{{ i18n "pages.inbounds.export"}}
</a-menu-item>
</template>
2023-03-17 19:07:49 +03:00
<template v-else>
<a-menu-item key="showInfo">
<a-icon type="info-circle"></a-icon>
{{ i18n "info"}}
</a-menu-item>
</template>
2023-02-09 22:18:06 +03:00
<a-menu-item key="resetTraffic">
<a-icon type="retweet"></a-icon> {{ i18n "pages.inbounds.resetTraffic" }}
2023-03-27 19:41:28 +03:00
</a-menu-item>
<a-menu-item key="clone">
2023-03-27 19:41:28 +03:00
<a-icon type="block"></a-icon> {{ i18n "pages.inbounds.Clone"}}
2023-02-09 22:18:06 +03:00
</a-menu-item>
<a-menu-item key="delete">
<span style="color: #FF4D4F">
<a-icon type="delete"></a-icon> {{ i18n "delete"}}
</span>
</a-menu-item>
</a-menu>
</a-dropdown>
</template>
<template slot="protocol" slot-scope="text, dbInbound">
<a-tag style="margin:0;" color="blue">[[ dbInbound.protocol ]]</a-tag>
<template v-if="dbInbound.isVMess || dbInbound.isVLess || dbInbound.isTrojan || dbInbound.isSS">
<a-tag style="margin:0;" color="green">[[ dbInbound.toInbound().stream.network ]]</a-tag>
<a-tag style="margin:0;" v-if="dbInbound.toInbound().stream.isTls" color="cyan">TLS</a-tag>
<a-tag style="margin:0;" v-if="dbInbound.toInbound().stream.isXtls" color="cyan">XTLS</a-tag>
2023-04-10 19:28:52 +03:00
<a-tag style="margin:0;" v-if="dbInbound.toInbound().stream.isReality" color="cyan">Reality</a-tag>
</template>
</template>
<template slot="clients" slot-scope="text, dbInbound">
<template v-if="clientCount[dbInbound.id]">
<a-tag style="margin:0;" color="green">[[ clientCount[dbInbound.id].clients ]]</a-tag>
<a-popover title='{{ i18n "disabled" }}' :overlay-class-name="siderDrawer.isDarkTheme ? 'ant-dark' : ''">
<template slot="content">
<p v-for="clientEmail in clientCount[dbInbound.id].deactive">[[ clientEmail ]]</p>
</template>
<a-tag style="margin:0; padding: 0 2px;" v-if="clientCount[dbInbound.id].deactive.length">[[ clientCount[dbInbound.id].deactive.length ]]</a-tag>
</a-popover>
<a-popover title='{{ i18n "depleted" }}' :overlay-class-name="siderDrawer.isDarkTheme ? 'ant-dark' : ''">
<template slot="content">
<p v-for="clientEmail in clientCount[dbInbound.id].depleted">[[ clientEmail ]]</p>
</template>
<a-tag style="margin:0; padding: 0 2px;" color="red" v-if="clientCount[dbInbound.id].depleted.length">[[ clientCount[dbInbound.id].depleted.length ]]</a-tag>
</a-popover>
<a-popover title='{{ i18n "depletingSoon" }}' :overlay-class-name="siderDrawer.isDarkTheme ? 'ant-dark' : ''">
<template slot="content">
<p v-for="clientEmail in clientCount[dbInbound.id].expiring">[[ clientEmail ]]</p>
</template>
<a-tag style="margin:0; padding: 0 2px;" color="orange" v-if="clientCount[dbInbound.id].expiring.length">[[ clientCount[dbInbound.id].expiring.length ]]</a-tag>
</a-popover>
</template>
2023-02-09 22:18:06 +03:00
</template>
<template slot="traffic" slot-scope="text, dbInbound">
<a-tag color="blue">[[ sizeFormat(dbInbound.up) ]] / [[ sizeFormat(dbInbound.down) ]]</a-tag>
<template v-if="dbInbound.total > 0">
<a-tag v-if="dbInbound.up + dbInbound.down < dbInbound.total" color="cyan">[[ sizeFormat(dbInbound.total) ]]</a-tag>
<a-tag v-else color="red">[[ sizeFormat(dbInbound.total) ]]</a-tag>
</template>
<a-tag v-else color="green">{{ i18n "unlimited" }}</a-tag>
</template>
<template slot="enable" slot-scope="text, dbInbound">
2023-03-17 19:07:49 +03:00
<a-switch v-model="dbInbound.enable" @change="switchEnable(dbInbound.id)"></a-switch>
2023-02-09 22:18:06 +03:00
</template>
<template slot="expiryTime" slot-scope="text, dbInbound">
<template v-if="dbInbound.expiryTime > 0">
<a-tag v-if="dbInbound.isExpiry" color="red">
[[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
</a-tag>
<a-tag v-else color="blue">
[[ DateUtil.formatMillis(dbInbound.expiryTime) ]]
</a-tag>
</template>
<a-tag v-else color="green">{{ i18n "indefinite" }}</a-tag>
</template>
<template slot="expandedRowRender" slot-scope="record">
<a-table
2023-02-12 16:50:09 +03:00
v-if="(record.protocol === Protocols.VLESS) || (record.protocol === Protocols.VMESS)"
2023-02-09 22:18:06 +03:00
:row-key="client => client.id"
:columns="innerColumns"
:data-source="getInboundClients(record)"
:pagination="false"
>
2023-03-17 19:07:49 +03:00
{{template "client_table"}}
2023-02-12 16:50:09 +03:00
</a-table>
<a-table
v-else-if="record.protocol === Protocols.TROJAN"
:row-key="client => client.id"
:columns="innerTrojanColumns"
:data-source="getInboundClients(record)"
:pagination="false"
>
2023-03-17 19:07:49 +03:00
{{template "client_table"}}
2023-02-09 22:18:06 +03:00
</a-table>
</template>
</a-table>
</a-card>
</transition>
</a-spin>
</a-layout-content>
</a-layout>
</a-layout>
{{template "js" .}}
<script>
const columns = [{
title: '{{ i18n "pages.inbounds.operate" }}',
align: 'center',
2023-02-18 18:55:53 +03:00
width: 60,
2023-02-09 22:18:06 +03:00
scopedSlots: { customRender: 'action' },
}, {
title: '{{ i18n "pages.inbounds.enable" }}',
align: 'center',
width: 40,
scopedSlots: { customRender: 'enable' },
2023-02-18 15:37:32 +03:00
}, {
2023-03-17 19:07:49 +03:00
title: "ID",
2023-02-18 15:37:32 +03:00
align: 'center',
dataIndex: "id",
2023-02-18 18:55:53 +03:00
width: 30,
2023-02-09 22:18:06 +03:00
}, {
title: '{{ i18n "pages.inbounds.remark" }}',
align: 'center',
2023-02-18 18:55:53 +03:00
width: 80,
2023-02-09 22:18:06 +03:00
dataIndex: "remark",
}, {
title: '{{ i18n "pages.inbounds.port" }}',
align: 'center',
dataIndex: "port",
2023-02-12 16:50:09 +03:00
width: 40,
}, {
title: '{{ i18n "pages.inbounds.protocol" }}',
align: 'left',
2023-04-10 19:28:52 +03:00
width: 80,
scopedSlots: { customRender: 'protocol' },
}, {
title: '{{ i18n "clients" }}',
align: 'left',
width: 50,
scopedSlots: { customRender: 'clients' },
2023-02-09 22:18:06 +03:00
}, {
title: '{{ i18n "pages.inbounds.traffic" }}↑|↓',
align: 'center',
width: 120,
2023-02-09 22:18:06 +03:00
scopedSlots: { customRender: 'traffic' },
}, {
title: '{{ i18n "pages.inbounds.expireDate" }}',
align: 'center',
width: 80,
scopedSlots: { customRender: 'expiryTime' },
}];
const innerColumns = [
2023-03-17 19:07:49 +03:00
{ title: '{{ i18n "pages.inbounds.operate" }}', width: 70, scopedSlots: { customRender: 'actions' } },
{ title: '{{ i18n "pages.inbounds.enable" }}', width: 30, scopedSlots: { customRender: 'enable' } },
{ title: '{{ i18n "pages.inbounds.client" }}', width: 80, scopedSlots: { customRender: 'client' } },
2023-04-10 14:03:50 +03:00
{ title: '{{ i18n "pages.inbounds.traffic" }}↑|↓', width: 120, scopedSlots: { customRender: 'traffic' } },
2023-02-16 18:58:20 +03:00
{ title: '{{ i18n "pages.inbounds.expireDate" }}', width: 70, scopedSlots: { customRender: 'expiryTime' } },
{ title: 'UID', width: 120, dataIndex: "id" },
2023-02-12 16:50:09 +03:00
];
2023-02-12 16:50:09 +03:00
const innerTrojanColumns = [
2023-03-17 19:07:49 +03:00
{ title: '{{ i18n "pages.inbounds.operate" }}', width: 70, scopedSlots: { customRender: 'actions' } },
{ title: '{{ i18n "pages.inbounds.enable" }}', width: 30, scopedSlots: { customRender: 'enable' } },
{ title: '{{ i18n "pages.inbounds.client" }}', width: 80, scopedSlots: { customRender: 'client' } },
2023-04-10 14:03:50 +03:00
{ title: '{{ i18n "pages.inbounds.traffic" }}↑|↓', width: 120, scopedSlots: { customRender: 'traffic' } },
2023-02-16 18:58:20 +03:00
{ title: '{{ i18n "pages.inbounds.expireDate" }}', width: 70, scopedSlots: { customRender: 'expiryTime' } },
2023-04-10 14:03:50 +03:00
{ title: 'Password', width: 120, dataIndex: "password" },
2023-02-12 16:50:09 +03:00
];
2023-02-09 22:18:06 +03:00
const app = new Vue({
delimiters: ['[[', ']]'],
el: '#app',
data: {
siderDrawer,
spinning: false,
inbounds: [],
dbInbounds: [],
searchKey: '',
2023-02-12 16:50:09 +03:00
searchedInbounds: [],
expireDiff: 0,
trafficDiff: 0,
defaultCert: '',
defaultKey: '',
clientCount: {},
2023-02-09 22:18:06 +03:00
},
methods: {
loading(spinning=true) {
this.spinning = spinning;
},
async getDBInbounds() {
this.loading();
const msg = await HttpUtil.post('/xui/inbound/list');
this.loading(false);
if (!msg.success) {
return;
}
this.setInbounds(msg.obj);
2023-03-17 19:07:49 +03:00
this.searchKey = '';
2023-02-09 22:18:06 +03:00
},
async getDefaultSettings() {
this.loading();
const msg = await HttpUtil.post('/xui/setting/defaultSettings');
this.loading(false);
if (!msg.success) {
return;
}
this.expireDiff = msg.obj.expireDiff * 86400000;
this.trafficDiff = msg.obj.trafficDiff * 1073741824;
this.defaultCert = msg.obj.defaultCert;
this.defaultKey = msg.obj.defaultKey;
},
2023-02-09 22:18:06 +03:00
setInbounds(dbInbounds) {
this.inbounds.splice(0);
this.dbInbounds.splice(0);
2023-02-12 16:50:09 +03:00
this.searchedInbounds.splice(0);
2023-02-09 22:18:06 +03:00
for (const inbound of dbInbounds) {
const dbInbound = new DBInbound(inbound);
to_inbound = dbInbound.toInbound()
this.inbounds.push(to_inbound);
2023-02-09 22:18:06 +03:00
this.dbInbounds.push(dbInbound);
2023-02-12 16:50:09 +03:00
this.searchedInbounds.push(dbInbound);
if([Protocols.VMESS, Protocols.VLESS, Protocols.TROJAN].includes(inbound.protocol) ){
this.clientCount[inbound.id] = this.getClientCounts(inbound,to_inbound);
}
}
},
getClientCounts(dbInbound,inbound){
let clientCount = 0,active = [], deactive = [], depleted = [], expiring = [];
clients = this.getClients(dbInbound.protocol, inbound.settings);
clientStats = dbInbound.clientStats
now = new Date().getTime()
if(clients){
clientCount = clients.length;
if(dbInbound.enable){
clients.forEach(client => {
client.enable ? active.push(client.email) : deactive.push(client.email);
});
clientStats.forEach(client => {
if(!client.enable) {
depleted.push(client.email);
} else {
if ((client.expiryTime > 0 && (client.expiryTime-now < this.expireDiff)) ||
2023-04-10 00:25:47 +03:00
(client.total > 0 && (client.total-(client.up+client.down) < this.trafficDiff ))) expiring.push(client.email);
}
});
} else {
clients.forEach(client => {
deactive.push(client.email);
});
}
2023-02-09 22:18:06 +03:00
}
return {
clients: clientCount,
active: active,
deactive: deactive,
depleted: depleted,
expiring: expiring,
};
2023-02-09 22:18:06 +03:00
},
searchInbounds(key) {
if (ObjectUtil.isEmpty(key)) {
this.searchedInbounds = this.dbInbounds.slice();
} else {
this.searchedInbounds.splice(0, this.searchedInbounds.length);
this.dbInbounds.forEach(inbound => {
if (ObjectUtil.deepSearch(inbound, key)) {
2023-02-16 18:58:20 +03:00
const newInbound = new DBInbound(inbound);
const inboundSettings = JSON.parse(inbound.settings);
if (inboundSettings.hasOwnProperty('clients')){
const searchedSettings = { "clients": [] };
inboundSettings.clients.forEach(client => {
if (ObjectUtil.deepSearch(client, key)){
searchedSettings.clients.push(client);
}
});
newInbound.settings = Inbound.Settings.fromJson(inbound.protocol, searchedSettings);
}
this.searchedInbounds.push(newInbound);
2023-02-09 22:18:06 +03:00
}
});
}
},
clickAction(action, dbInbound) {
switch (action.key) {
case "qrcode":
this.showQrcode(dbInbound);
break;
2023-03-17 19:07:49 +03:00
case "showInfo":
this.showInfo(dbInbound);
2023-03-17 01:01:14 +03:00
break;
2023-02-09 22:18:06 +03:00
case "edit":
2023-02-18 15:37:32 +03:00
this.openEditInbound(dbInbound.id);
2023-02-09 22:18:06 +03:00
break;
2023-03-17 19:07:49 +03:00
case "addClient":
this.openAddClient(dbInbound.id)
break;
case "addBulkClient":
this.openAddBulkClient(dbInbound.id)
break;
case "export":
this.inboundLinks(dbInbound.id);
break;
2023-02-09 22:18:06 +03:00
case "resetTraffic":
2023-03-17 19:07:49 +03:00
this.resetTraffic(dbInbound.id);
2023-03-27 19:41:28 +03:00
break;
case "resetClients":
this.resetAllClientTraffics(dbInbound.id);
break;
case "clone":
2023-03-27 19:41:28 +03:00
this.openCloneInbound(dbInbound);
2023-02-09 22:18:06 +03:00
break;
case "delete":
2023-03-17 19:07:49 +03:00
this.delInbound(dbInbound.id);
2023-02-09 22:18:06 +03:00
break;
}
2023-03-27 19:41:28 +03:00
},
openCloneInbound(dbInbound) {
this.$confirm({
title: '{{ i18n "pages.inbounds.cloneInbound"}}' + dbInbound.remark,
2023-03-27 19:41:28 +03:00
content: '{{ i18n "pages.inbounds.cloneInboundContent"}}',
okText: '{{ i18n "pages.inbounds.cloneInboundOk"}}',
cancelText: '{{ i18n "cancel" }}',
onOk: () => {
const baseInbound = dbInbound.toInbound();
dbInbound.up = 0;
dbInbound.down = 0;
this.cloneInbound(baseInbound, dbInbound);
},
});
},
async cloneInbound(baseInbound, dbInbound) {
const inbound = new Inbound();
const data = {
up: dbInbound.up,
down: dbInbound.down,
total: dbInbound.total,
remark: dbInbound.remark + " - Cloned",
enable: dbInbound.enable,
expiryTime: dbInbound.expiryTime,
listen: inbound.listen,
port: inbound.port,
protocol: baseInbound.protocol,
settings: inbound.settings.toString(),
streamSettings: baseInbound.stream.toString(),
sniffing: baseInbound.canSniffing() ? baseInbound.sniffing.toString() : '{}',
};
await this.submit('/xui/inbound/add', data, inModal);
2023-02-09 22:18:06 +03:00
},
openAddInbound() {
inModal.show({
title: '{{ i18n "pages.inbounds.addInbound"}}',
okText: '{{ i18n "pages.inbounds.addTo"}}',
cancelText: '{{ i18n "close" }}',
confirm: async (inbound, dbInbound) => {
inModal.loading();
await this.addInbound(inbound, dbInbound);
inModal.close();
},
isEdit: false
});
},
2023-03-17 19:07:49 +03:00
openEditInbound(dbInboundId) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
2023-02-09 22:18:06 +03:00
const inbound = dbInbound.toInbound();
inModal.show({
title: '{{ i18n "pages.inbounds.modifyInbound"}}',
okText: '{{ i18n "pages.inbounds.revise"}}',
cancelText: '{{ i18n "close" }}',
inbound: inbound,
dbInbound: dbInbound,
confirm: async (inbound, dbInbound) => {
inModal.loading();
await this.updateInbound(inbound, dbInbound);
inModal.close();
},
isEdit: true
});
},
async addInbound(inbound, dbInbound) {
const data = {
up: dbInbound.up,
down: dbInbound.down,
total: dbInbound.total,
remark: dbInbound.remark,
enable: dbInbound.enable,
expiryTime: dbInbound.expiryTime,
listen: inbound.listen,
port: inbound.port,
protocol: inbound.protocol,
settings: inbound.settings.toString(),
};
2023-03-17 19:07:49 +03:00
if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
if (inbound.canSniffing()) data.sniffing = inbound.sniffing.toString();
2023-02-09 22:18:06 +03:00
await this.submit('/xui/inbound/add', data, inModal);
},
async updateInbound(inbound, dbInbound) {
const data = {
up: dbInbound.up,
down: dbInbound.down,
total: dbInbound.total,
remark: dbInbound.remark,
enable: dbInbound.enable,
expiryTime: dbInbound.expiryTime,
listen: inbound.listen,
port: inbound.port,
protocol: inbound.protocol,
settings: inbound.settings.toString(),
};
2023-03-17 19:07:49 +03:00
if (inbound.canEnableStream()) data.streamSettings = inbound.stream.toString();
if (inbound.canSniffing()) data.sniffing = inbound.sniffing.toString();
2023-02-09 22:18:06 +03:00
await this.submit(`/xui/inbound/update/${dbInbound.id}`, data, inModal);
},
2023-03-17 19:07:49 +03:00
openAddClient(dbInboundId) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
clientModal.show({
title: '{{ i18n "pages.client.add"}}',
okText: '{{ i18n "pages.client.submitAdd"}}',
dbInbound: dbInbound,
confirm: async (clients, dbInboundId) => {
2023-03-17 19:07:49 +03:00
clientModal.loading();
await this.addClient(clients, dbInboundId);
2023-03-17 19:07:49 +03:00
clientModal.close();
},
isEdit: false
});
},
openAddBulkClient(dbInboundId) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
clientsBulkModal.show({
title: '{{ i18n "pages.client.bulk"}} ' + dbInbound.remark,
okText: '{{ i18n "pages.client.bulk"}}',
dbInbound: dbInbound,
confirm: async (clients, dbInboundId) => {
2023-03-17 19:07:49 +03:00
clientsBulkModal.loading();
await this.addClient(clients, dbInboundId);
2023-03-17 19:07:49 +03:00
clientsBulkModal.close();
},
});
},
openEditClient(dbInboundId, client) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
clients = this.getInboundClients(dbInbound);
index = this.findIndexOfClient(clients, client);
clientModal.show({
title: '{{ i18n "pages.client.edit"}}',
okText: '{{ i18n "pages.client.submitEdit"}}',
dbInbound: dbInbound,
index: index,
confirm: async (client, dbInboundId, index) => {
2023-03-17 19:07:49 +03:00
clientModal.loading();
await this.updateClient(client, dbInboundId, index);
2023-03-17 19:07:49 +03:00
clientModal.close();
},
isEdit: true
});
},
findIndexOfClient(clients,client) {
firstKey = Object.keys(client)[0];
return clients.findIndex(c => c[firstKey] === client[firstKey]);
},
async addClient(clients, dbInboundId) {
2023-03-17 19:07:49 +03:00
const data = {
id: dbInboundId,
settings: '{"clients": [' + clients.toString() +']}',
2023-03-17 19:07:49 +03:00
};
await this.submit(`/xui/inbound/addClient`, data);
2023-03-17 19:07:49 +03:00
},
async updateClient(client, dbInboundId, index) {
2023-03-17 19:07:49 +03:00
const data = {
id: dbInboundId,
settings: '{"clients": [' + client.toString() +']}',
2023-03-17 19:07:49 +03:00
};
await this.submit(`/xui/inbound/updateClient/${index}`, data);
},
resetTraffic(dbInboundId) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
2023-02-09 22:18:06 +03:00
this.$confirm({
title: '{{ i18n "pages.inbounds.resetTraffic"}}',
content: '{{ i18n "pages.inbounds.resetTrafficContent"}}',
2023-03-17 19:07:49 +03:00
class: siderDrawer.isDarkTheme ? darkClass : '',
2023-02-09 22:18:06 +03:00
okText: '{{ i18n "reset"}}',
cancelText: '{{ i18n "cancel"}}',
onOk: () => {
const inbound = dbInbound.toInbound();
dbInbound.up = 0;
dbInbound.down = 0;
this.updateInbound(inbound, dbInbound);
},
});
},
2023-03-17 19:07:49 +03:00
delInbound(dbInboundId) {
2023-02-09 22:18:06 +03:00
this.$confirm({
title: '{{ i18n "pages.inbounds.deleteInbound"}}',
content: '{{ i18n "pages.inbounds.deleteInboundContent"}}',
2023-03-17 19:07:49 +03:00
class: siderDrawer.isDarkTheme ? darkClass : '',
2023-02-09 22:18:06 +03:00
okText: '{{ i18n "delete"}}',
cancelText: '{{ i18n "cancel"}}',
2023-03-17 19:07:49 +03:00
onOk: () => this.submit('/xui/inbound/del/' + dbInboundId),
2023-02-09 22:18:06 +03:00
});
},
2023-03-17 19:07:49 +03:00
delClient(dbInboundId,client) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
clientId = dbInbound.protocol == "trojan" ? client.password : client.id;
2023-03-17 19:07:49 +03:00
this.$confirm({
title: '{{ i18n "pages.inbounds.deleteInbound"}}',
content: '{{ i18n "pages.inbounds.deleteInboundContent"}}',
class: siderDrawer.isDarkTheme ? darkClass : '',
okText: '{{ i18n "delete"}}',
cancelText: '{{ i18n "cancel"}}',
onOk: () => this.submit(`/xui/inbound/${dbInboundId}/delClient/${clientId}`),
2023-03-17 19:07:49 +03:00
});
},
getClients(protocol, clientSettings) {
2023-03-17 01:01:14 +03:00
switch(protocol){
case Protocols.VMESS: return clientSettings.vmesses;
case Protocols.VLESS: return clientSettings.vlesses;
case Protocols.TROJAN: return clientSettings.trojans;
default: return null;
}
},
2023-03-17 19:07:49 +03:00
showQrcode(dbInbound, clientIndex) {
2023-02-12 16:50:09 +03:00
const link = dbInbound.genLink(clientIndex);
2023-02-09 22:18:06 +03:00
qrModal.show('{{ i18n "qrCode"}}', link, dbInbound);
},
2023-02-12 16:50:09 +03:00
showInfo(dbInbound, index) {
infoModal.show(dbInbound, index);
2023-02-09 22:18:06 +03:00
},
2023-03-17 19:07:49 +03:00
switchEnable(dbInboundId) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
this.submit(`/xui/inbound/update/${dbInboundId}`, dbInbound);
2023-02-09 22:18:06 +03:00
},
async switchEnableClient(dbInboundId, client) {
this.loading()
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
inbound = dbInbound.toInbound();
clients = this.getClients(dbInbound.protocol, inbound.settings);
index = this.findIndexOfClient(clients, client);
clients[index].enable = !clients[index].enable;
await this.updateClient(clients[index],dbInboundId, index);
this.loading(false);
},
2023-03-17 19:07:49 +03:00
async submit(url, data) {
const msg = await HttpUtil.postWithModal(url, data);
2023-02-09 22:18:06 +03:00
if (msg.success) {
await this.getDBInbounds();
}
},
getInboundClients(dbInbound) {
if(dbInbound.protocol == Protocols.VLESS) {
return dbInbound.toInbound().settings.vlesses
} else if(dbInbound.protocol == Protocols.VMESS) {
return dbInbound.toInbound().settings.vmesses
} else if(dbInbound.protocol == Protocols.TROJAN) {
return dbInbound.toInbound().settings.trojans
}
},
2023-03-17 19:07:49 +03:00
resetClientTraffic(client,dbInboundId) {
2023-02-12 16:50:09 +03:00
this.$confirm({
title: '{{ i18n "pages.inbounds.resetTraffic"}}',
content: '{{ i18n "pages.inbounds.resetTrafficContent"}}',
2023-03-17 19:07:49 +03:00
class: siderDrawer.isDarkTheme ? darkClass : '',
2023-02-12 16:50:09 +03:00
okText: '{{ i18n "reset"}}',
cancelText: '{{ i18n "cancel"}}',
2023-03-17 19:07:49 +03:00
onOk: () => this.submit('/xui/inbound/' + dbInboundId + '/resetClientTraffic/'+ client.email),
})
2023-02-12 16:50:09 +03:00
},
resetAllTraffic() {
this.$confirm({
title: '{{ i18n "pages.inbounds.resetAllTrafficTitle"}}',
content: '{{ i18n "pages.inbounds.resetAllTrafficContent"}}',
class: siderDrawer.isDarkTheme ? darkClass : '',
okText: '{{ i18n "reset"}}',
cancelText: '{{ i18n "cancel"}}',
onOk: () => this.submit('/xui/inbound/resetAllTraffics'),
});
},
resetAllClientTraffics(dbInboundId) {
this.$confirm({
title: '{{ i18n "pages.inbounds.resetAllClientTrafficTitle"}}',
content: '{{ i18n "pages.inbounds.resetAllClientTrafficContent"}}',
class: siderDrawer.isDarkTheme ? darkClass : '',
okText: '{{ i18n "reset"}}',
cancelText: '{{ i18n "cancel"}}',
onOk: () => this.submit('/xui/inbound/resetAllClientTraffics/' + dbInboundId),
})
},
2023-02-09 22:18:06 +03:00
isExpiry(dbInbound, index) {
return dbInbound.toInbound().isExpiry(index)
},
getUpStats(dbInbound, email) {
2023-03-17 01:01:14 +03:00
if(email.length == 0) return 0
clientStats = dbInbound.clientStats.find(stats => stats.email === email)
return clientStats ? clientStats.up : 0
2023-02-09 22:18:06 +03:00
},
getDownStats(dbInbound, email) {
2023-03-17 01:01:14 +03:00
if(email.length == 0) return 0
clientStats = dbInbound.clientStats.find(stats => stats.email === email)
return clientStats ? clientStats.down : 0
2023-02-09 22:18:06 +03:00
},
isTrafficExhausted(dbInbound, email) {
2023-03-17 01:01:14 +03:00
if(email.length == 0) return false
clientStats = dbInbound.clientStats.find(stats => stats.email === email)
return clientStats ? clientStats.down + clientStats.up > clientStats.total : false
},
2023-03-17 19:07:49 +03:00
isClientEnabled(dbInbound, email) {
clientStats = dbInbound.clientStats ? dbInbound.clientStats.find(stats => stats.email === email) : null
return clientStats ? clientStats['enable'] : true
},
isRemovable(dbInbound_id){
return this.getInboundClients(this.dbInbounds.find(row => row.id === dbInbound_id)).length > 1
},
2023-03-17 01:01:14 +03:00
inboundLinks(dbInboundId) {
dbInbound = this.dbInbounds.find(row => row.id === dbInboundId);
txtModal.show('{{ i18n "pages.inbounds.export"}}',dbInbound.genInboundLinks,dbInbound.remark);
},
exportAllLinks() {
let copyText = '';
for (const dbInbound of this.dbInbounds) {
copyText += dbInbound.genInboundLinks
2023-02-09 22:18:06 +03:00
}
2023-03-17 01:01:14 +03:00
txtModal.show('{{ i18n "pages.inbounds.export"}}',copyText,'All-Inbounds');
2023-02-09 22:18:06 +03:00
},
},
watch: {
2023-02-12 16:50:09 +03:00
searchKey: debounce(function (newVal) {
this.searchInbounds(newVal);
}, 500)
2023-02-09 22:18:06 +03:00
},
mounted() {
this.getDefaultSettings();
2023-02-09 22:18:06 +03:00
this.getDBInbounds();
},
computed: {
total() {
let down = 0, up = 0;
let clients = 0, deactive = [], depleted = [], expiring = [];
2023-03-17 01:01:14 +03:00
this.dbInbounds.forEach(dbInbound => {
down += dbInbound.down;
up += dbInbound.up;
if (this.clientCount[dbInbound.id]) {
clients += this.clientCount[dbInbound.id].clients;
deactive = deactive.concat(this.clientCount[dbInbound.id].deactive);
depleted = depleted.concat(this.clientCount[dbInbound.id].depleted);
expiring = expiring.concat(this.clientCount[dbInbound.id].expiring);
2023-03-17 01:01:14 +03:00
}
});
2023-02-09 22:18:06 +03:00
return {
down: down,
up: up,
clients: clients,
2023-03-17 01:01:14 +03:00
deactive: deactive,
depleted: depleted,
expiring: expiring,
2023-02-09 22:18:06 +03:00
};
}
},
});
</script>
{{template "inboundModal"}}
{{template "promptModal"}}
{{template "qrcodeModal"}}
{{template "textModal"}}
{{template "inboundInfoModal"}}
2023-03-17 19:07:49 +03:00
{{template "clientsModal"}}
{{template "clientsBulkModal"}}
2023-02-09 22:18:06 +03:00
</body>
2023-03-17 19:07:49 +03:00
</html>