2023-02-09 22:18:06 +03:00
|
|
|
{{define "inboundModal"}}
|
2024-03-11 15:44:24 +03:00
|
|
|
<a-modal id="inbound-modal" v-model="inModal.visible" :title="inModal.title"
|
|
|
|
:dialog-style="{ top: '20px' }" @ok="inModal.ok"
|
|
|
|
:confirm-loading="inModal.confirmLoading" :closable="true" :mask-closable="false"
|
|
|
|
:class="themeSwitcher.currentTheme"
|
|
|
|
:ok-text="inModal.okText" cancel-text='{{ i18n "close" }}'>
|
2023-02-09 22:18:06 +03:00
|
|
|
{{template "form/inbound"}}
|
|
|
|
</a-modal>
|
|
|
|
<script>
|
|
|
|
|
|
|
|
const inModal = {
|
|
|
|
title: '',
|
|
|
|
visible: false,
|
|
|
|
confirmLoading: false,
|
|
|
|
okText: '{{ i18n "sure" }}',
|
|
|
|
isEdit: false,
|
|
|
|
confirm: null,
|
|
|
|
inbound: new Inbound(),
|
|
|
|
dbInbound: new DBInbound(),
|
|
|
|
ok() {
|
|
|
|
ObjectUtil.execute(inModal.confirm, inModal.inbound, inModal.dbInbound);
|
|
|
|
},
|
2023-05-08 17:44:22 +03:00
|
|
|
show({ title = '', okText = '{{ i18n "sure" }}', inbound = null, dbInbound = null, confirm = (inbound, dbInbound) => {}, isEdit = false }) {
|
2023-02-09 22:18:06 +03:00
|
|
|
this.title = title;
|
|
|
|
this.okText = okText;
|
|
|
|
if (inbound) {
|
|
|
|
this.inbound = Inbound.fromJson(inbound.toJson());
|
|
|
|
} else {
|
|
|
|
this.inbound = new Inbound();
|
|
|
|
}
|
|
|
|
if (dbInbound) {
|
|
|
|
this.dbInbound = new DBInbound(dbInbound);
|
|
|
|
} else {
|
|
|
|
this.dbInbound = new DBInbound();
|
|
|
|
}
|
|
|
|
this.confirm = confirm;
|
|
|
|
this.visible = true;
|
|
|
|
this.isEdit = isEdit;
|
|
|
|
},
|
|
|
|
close() {
|
|
|
|
inModal.visible = false;
|
|
|
|
inModal.loading(false);
|
|
|
|
},
|
2024-02-21 14:39:56 +03:00
|
|
|
loading(loading=true) {
|
2023-02-09 22:18:06 +03:00
|
|
|
inModal.confirmLoading = loading;
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
new Vue({
|
|
|
|
delimiters: ['[[', ']]'],
|
|
|
|
el: '#inbound-modal',
|
|
|
|
data: {
|
|
|
|
inModal: inModal,
|
2023-04-18 21:04:06 +03:00
|
|
|
delayedStart: false,
|
2023-02-09 22:18:06 +03:00
|
|
|
get inbound() {
|
|
|
|
return inModal.inbound;
|
|
|
|
},
|
|
|
|
get dbInbound() {
|
|
|
|
return inModal.dbInbound;
|
|
|
|
},
|
|
|
|
get isEdit() {
|
|
|
|
return inModal.isEdit;
|
|
|
|
},
|
2023-04-18 21:04:06 +03:00
|
|
|
get client() {
|
2023-12-08 20:45:21 +03:00
|
|
|
return inModal.inbound.clients[0];
|
2023-02-09 22:18:06 +03:00
|
|
|
},
|
2024-01-02 11:32:21 +03:00
|
|
|
get datepicker() {
|
|
|
|
return app.datepicker;
|
|
|
|
},
|
2023-04-18 21:04:06 +03:00
|
|
|
get delayedExpireDays() {
|
|
|
|
return this.client && this.client.expiryTime < 0 ? this.client.expiryTime / -86400000 : 0;
|
2023-02-09 22:18:06 +03:00
|
|
|
},
|
2023-05-08 17:44:22 +03:00
|
|
|
set delayedExpireDays(days) {
|
2023-04-18 21:04:06 +03:00
|
|
|
this.client.expiryTime = -86400000 * days;
|
2023-02-09 22:18:06 +03:00
|
|
|
},
|
2023-12-08 20:45:21 +03:00
|
|
|
get externalProxy() {
|
|
|
|
return this.inbound.stream.externalProxy.length > 0;
|
2023-05-22 17:01:41 +03:00
|
|
|
},
|
2023-12-08 20:45:21 +03:00
|
|
|
set externalProxy(value) {
|
2023-05-22 17:01:41 +03:00
|
|
|
if (value) {
|
2023-12-08 20:45:21 +03:00
|
|
|
inModal.inbound.stream.externalProxy = [{
|
|
|
|
forceTls: "same",
|
|
|
|
dest: window.location.hostname,
|
|
|
|
port: inModal.inbound.port,
|
|
|
|
remark: ""
|
|
|
|
}];
|
2023-05-22 17:01:41 +03:00
|
|
|
} else {
|
2023-12-08 20:45:21 +03:00
|
|
|
inModal.inbound.stream.externalProxy = [];
|
2023-05-22 17:01:41 +03:00
|
|
|
}
|
|
|
|
}
|
2023-04-18 21:04:06 +03:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
streamNetworkChange() {
|
2023-12-08 18:46:44 +03:00
|
|
|
if (!inModal.inbound.canEnableTls()) {
|
2023-04-18 21:04:06 +03:00
|
|
|
this.inModal.inbound.stream.security = 'none';
|
|
|
|
}
|
|
|
|
if (!inModal.inbound.canEnableReality()) {
|
|
|
|
this.inModal.inbound.reality = false;
|
|
|
|
}
|
2023-07-18 01:24:26 +03:00
|
|
|
if (this.inModal.inbound.protocol == Protocols.VLESS && !inModal.inbound.canEnableTlsFlow()) {
|
|
|
|
this.inModal.inbound.settings.vlesses.forEach(client => {
|
|
|
|
client.flow = "";
|
2023-12-13 18:57:36 +03:00
|
|
|
});
|
|
|
|
}
|
2023-02-09 22:18:06 +03:00
|
|
|
},
|
2023-07-18 02:49:01 +03:00
|
|
|
SSMethodChange() {
|
|
|
|
if (this.inModal.inbound.isSSMultiUser) {
|
|
|
|
if (this.inModal.inbound.settings.shadowsockses.length ==0){
|
|
|
|
this.inModal.inbound.settings.shadowsockses = [new Inbound.ShadowsocksSettings.Shadowsocks()];
|
|
|
|
}
|
2023-08-26 15:31:02 +03:00
|
|
|
if (!this.inModal.inbound.isSS2022) {
|
2023-07-27 11:28:12 +03:00
|
|
|
this.inModal.inbound.settings.shadowsockses.forEach(client => {
|
|
|
|
client.method = this.inModal.inbound.settings.method;
|
|
|
|
})
|
|
|
|
} else {
|
|
|
|
this.inModal.inbound.settings.shadowsockses.forEach(client => {
|
|
|
|
client.method = "";
|
|
|
|
})
|
|
|
|
}
|
2023-07-18 02:49:01 +03:00
|
|
|
} else {
|
|
|
|
if (this.inModal.inbound.settings.shadowsockses.length > 0){
|
|
|
|
this.inModal.inbound.settings.shadowsockses = [];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2023-05-17 00:25:19 +03:00
|
|
|
setDefaultCertData(index) {
|
|
|
|
inModal.inbound.stream.tls.certs[index].certFile = app.defaultCert;
|
|
|
|
inModal.inbound.stream.tls.certs[index].keyFile = app.defaultKey;
|
2023-04-09 22:43:18 +03:00
|
|
|
},
|
2023-05-08 17:44:22 +03:00
|
|
|
async getNewX25519Cert() {
|
2023-04-18 21:04:06 +03:00
|
|
|
inModal.loading(true);
|
|
|
|
const msg = await HttpUtil.post('/server/getNewX25519Cert');
|
|
|
|
inModal.loading(false);
|
|
|
|
if (!msg.success) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
inModal.inbound.stream.reality.privateKey = msg.obj.privateKey;
|
|
|
|
inModal.inbound.stream.reality.settings.publicKey = msg.obj.publicKey;
|
2023-02-09 22:18:06 +03:00
|
|
|
}
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
2023-03-17 19:07:49 +03:00
|
|
|
{{end}}
|