new: vless reverse
legacy reverse removed
This commit is contained in:
@@ -129,6 +129,18 @@
|
||||
<a-select-option v-for="key in TLS_FLOW_CONTROL" :value="key">[[ key ]]</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item v-if="inbound.protocol === Protocols.VLESS">
|
||||
<template slot="label">
|
||||
<a-tooltip>
|
||||
<template slot="title">
|
||||
<span>{{ i18n "pages.xray.outbound.reverseTagDesc" }}</span>
|
||||
</template>
|
||||
{{ i18n "pages.xray.outbound.reverseTag" }}
|
||||
<a-icon type="question-circle"></a-icon>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<a-input v-model.trim="client.reverseTag" :placeholder='`{{ i18n "pages.xray.outbound.reverseTagPlaceholder" }}`'></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<template slot="label">
|
||||
<a-tooltip>
|
||||
|
||||
@@ -342,6 +342,18 @@
|
||||
<a-form-item label="encryption">
|
||||
<a-input v-model.trim="outbound.settings.encryption"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item>
|
||||
<template slot="label">
|
||||
<a-tooltip>
|
||||
<template slot="title">
|
||||
<span>{{ i18n "pages.xray.outbound.reverseTagDesc" }}</span>
|
||||
</template>
|
||||
{{ i18n "pages.xray.outbound.reverseTag" }}
|
||||
<a-icon type="question-circle"></a-icon>
|
||||
</a-tooltip>
|
||||
</template>
|
||||
<a-input v-model.trim="outbound.settings.reverseTag" :placeholder='`{{ i18n "pages.xray.outbound.reverseTagPlaceholder" }}`'></a-input>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<template v-if="outbound.canEnableTlsFlow()">
|
||||
<a-form-item label="Flow">
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
{{define "modals/reverseModal"}}
|
||||
<a-modal id="reverse-modal" v-model="reverseModal.visible" :title="reverseModal.title" @ok="reverseModal.ok"
|
||||
:confirm-loading="reverseModal.confirmLoading" :closable="true" :mask-closable="false"
|
||||
:ok-text="reverseModal.okText" cancel-text='{{ i18n "close" }}' :class="themeSwitcher.currentTheme">
|
||||
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
|
||||
<a-form-item label='{{ i18n "pages.xray.outbound.type" }}'>
|
||||
<a-select v-model="reverseModal.reverse.type" :dropdown-class-name="themeSwitcher.currentTheme">
|
||||
<a-select-option v-for="x,y in reverseTypes" :value="y">[[ x ]]</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label='{{ i18n "pages.xray.outbound.tag" }}'>
|
||||
<a-input v-model.trim="reverseModal.reverse.tag"></a-input>
|
||||
</a-form-item>
|
||||
<a-form-item label='{{ i18n "pages.xray.outbound.domain" }}'>
|
||||
<a-input v-model.trim="reverseModal.reverse.domain"></a-input>
|
||||
</a-form-item>
|
||||
<template v-if="reverseModal.reverse.type=='bridge'">
|
||||
<a-form-item label='{{ i18n "pages.xray.outbound.intercon" }}'>
|
||||
<a-select v-model="reverseModal.rules[0].outboundTag" :dropdown-class-name="themeSwitcher.currentTheme">
|
||||
<a-select-option v-for="x in reverseModal.outboundTags" :value="x">[[ x ]]</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
<a-form-item label='{{ i18n "pages.xray.rules.outbound" }}'>
|
||||
<a-select v-model="reverseModal.rules[1].outboundTag" :dropdown-class-name="themeSwitcher.currentTheme">
|
||||
<a-select-option v-for="x in reverseModal.outboundTags" :value="x">[[ x ]]</a-select-option>
|
||||
</a-select>
|
||||
</a-form-item>
|
||||
</template>
|
||||
<template v-else>
|
||||
<a-form-item label='{{ i18n "pages.xray.outbound.intercon" }}'>
|
||||
<a-checkbox-group v-model="reverseModal.rules[0].inboundTag"
|
||||
:options="reverseModal.inboundTags"></a-checkbox-group>
|
||||
</a-form-item>
|
||||
<a-form-item label='{{ i18n "pages.xray.rules.inbound" }}'>
|
||||
<a-checkbox-group v-model="reverseModal.rules[1].inboundTag"
|
||||
:options="reverseModal.inboundTags"></a-checkbox-group>
|
||||
</a-form-item>
|
||||
</template>
|
||||
</a-form>
|
||||
</a-modal>
|
||||
<script>
|
||||
const reverseModal = {
|
||||
title: '',
|
||||
visible: false,
|
||||
confirmLoading: false,
|
||||
okText: '{{ i18n "sure" }}',
|
||||
isEdit: false,
|
||||
confirm: null,
|
||||
reverse: {
|
||||
tag: "",
|
||||
type: "",
|
||||
domain: ""
|
||||
},
|
||||
rules: [{
|
||||
outboundTag: '',
|
||||
inboundTag: []
|
||||
},
|
||||
{
|
||||
outboundTag: '',
|
||||
inboundTag: []
|
||||
}
|
||||
],
|
||||
inboundTags: [],
|
||||
outboundTags: [],
|
||||
ok() {
|
||||
reverseModal.rules[0].domain = ["full:" + reverseModal.reverse.domain];
|
||||
reverseModal.rules[0].type = 'field';
|
||||
reverseModal.rules[1].type = 'field';
|
||||
|
||||
if (reverseModal.reverse.type == 'bridge') {
|
||||
reverseModal.rules[0].inboundTag = [reverseModal.reverse.tag];
|
||||
reverseModal.rules[1].inboundTag = [reverseModal.reverse.tag];
|
||||
} else {
|
||||
reverseModal.rules[0].outboundTag = reverseModal.reverse.tag;
|
||||
reverseModal.rules[1].outboundTag = reverseModal.reverse.tag;
|
||||
}
|
||||
ObjectUtil.execute(reverseModal.confirm, reverseModal.reverse, reverseModal.rules);
|
||||
},
|
||||
show({
|
||||
title = '',
|
||||
okText = '{{ i18n "sure" }}',
|
||||
reverse,
|
||||
rules,
|
||||
confirm = (reverse, rules) => {},
|
||||
isEdit = false
|
||||
}) {
|
||||
this.title = title;
|
||||
this.okText = okText;
|
||||
this.confirm = confirm;
|
||||
this.visible = true;
|
||||
if (isEdit) {
|
||||
this.reverse = {
|
||||
tag: reverse.tag,
|
||||
type: reverse.type,
|
||||
domain: reverse.domain,
|
||||
};
|
||||
reverse;
|
||||
rules0 = rules.filter(r => r.domain != null);
|
||||
if (rules0.length == 0) rules0 = [{
|
||||
outboundTag: '',
|
||||
domain: ["full:" + this.reverse.domain],
|
||||
inboundTag: []
|
||||
}];
|
||||
rules1 = rules.filter(r => r.domain == null);
|
||||
if (rules1.length == 0) rules1 = [{
|
||||
outboundTag: '',
|
||||
inboundTag: []
|
||||
}];
|
||||
this.rules = [];
|
||||
this.rules.push({
|
||||
domain: rules0[0].domain,
|
||||
outboundTag: rules0[0].outboundTag,
|
||||
inboundTag: rules0.map(r => r.inboundTag).flat()
|
||||
});
|
||||
this.rules.push({
|
||||
outboundTag: rules1[0].outboundTag,
|
||||
inboundTag: rules1.map(r => r.inboundTag).flat()
|
||||
});
|
||||
} else {
|
||||
this.reverse = {
|
||||
tag: "reverse-" + app.reverseData.length,
|
||||
type: "bridge",
|
||||
domain: "reverse.xui"
|
||||
}
|
||||
this.rules = [{
|
||||
outboundTag: '',
|
||||
inboundTag: []
|
||||
},
|
||||
{
|
||||
outboundTag: '',
|
||||
inboundTag: []
|
||||
}
|
||||
]
|
||||
}
|
||||
this.isEdit = isEdit;
|
||||
this.inboundTags = app.templateSettings.inbounds.filter((i) => !ObjectUtil.isEmpty(i.tag)).map(obj =>
|
||||
obj.tag);
|
||||
this.inboundTags.push(...app.inboundTags);
|
||||
if (app.enableDNS && !ObjectUtil.isEmpty(app.dnsTag)) this.inboundTags.push(app.dnsTag)
|
||||
this.outboundTags = app.templateSettings.outbounds.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj =>
|
||||
obj.tag);
|
||||
},
|
||||
close() {
|
||||
reverseModal.visible = false;
|
||||
reverseModal.loading(false);
|
||||
},
|
||||
loading(loading = true) {
|
||||
reverseModal.confirmLoading = loading;
|
||||
},
|
||||
};
|
||||
|
||||
new Vue({
|
||||
delimiters: ['[[', ']]'],
|
||||
el: '#reverse-modal',
|
||||
data: {
|
||||
reverseModal: reverseModal,
|
||||
reverseTypes: {
|
||||
bridge: '{{ i18n "pages.xray.outbound.bridge" }}',
|
||||
portal: '{{ i18n "pages.xray.outbound.portal" }}'
|
||||
},
|
||||
},
|
||||
});
|
||||
</script>
|
||||
{{end}}
|
||||
@@ -204,13 +204,6 @@
|
||||
if (app.enableDNS && !ObjectUtil.isEmpty(app.dnsTag)) this.inboundTags.push(app.dnsTag)
|
||||
this.outboundTags = ["", ...app.templateSettings.outbounds.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj =>
|
||||
obj.tag)];
|
||||
if (app.templateSettings.reverse) {
|
||||
if (app.templateSettings.reverse.bridges) {
|
||||
this.inboundTags.push(...app.templateSettings.reverse.bridges.map(b => b.tag));
|
||||
}
|
||||
if (app.templateSettings.reverse.portals) this.outboundTags.push(...app.templateSettings.reverse.portals.map(
|
||||
b => b.tag));
|
||||
}
|
||||
this.balancerTags = [""];
|
||||
if (app.templateSettings.routing && app.templateSettings.routing.balancers) {
|
||||
this.balancerTags = ["", ...app.templateSettings.routing.balancers.filter((o) => !ObjectUtil.isEmpty(o.tag))
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
{{define "settings/xray/reverse"}}
|
||||
<template v-if="reverseData.length > 0">
|
||||
<a-space direction="vertical" size="middle">
|
||||
<a-button type="primary" icon="plus" @click="addReverse()">
|
||||
<span>{{ i18n "pages.xray.outbound.addReverse" }}</span>
|
||||
</a-button>
|
||||
<a-table :columns="reverseColumns" bordered :row-key="r => r.key" :data-source="reverseData"
|
||||
:scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
|
||||
:locale='{ filterConfirm: `{{ i18n "confirm" }}`, filterReset: `{{ i18n "reset" }}` }'>
|
||||
<template slot="action" slot-scope="text, reverse, index">
|
||||
<span>[[ index+1 ]]</span>
|
||||
<a-dropdown :trigger="['click']">
|
||||
<a-icon @click="e => e.preventDefault()" type="more"
|
||||
:style="{ fontSize: '16px', textDecoration: 'bold' }"></a-icon>
|
||||
<a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
|
||||
<a-menu-item @click="editReverse(index)">
|
||||
<a-icon type="edit"></a-icon>
|
||||
<span>{{ i18n "edit" }}</span>
|
||||
</a-menu-item>
|
||||
<a-menu-item @click="deleteReverse(index)">
|
||||
<span :style="{ color: '#FF4D4F' }">
|
||||
<a-icon type="delete"></a-icon>
|
||||
<span>{{ i18n "delete"}}</span>
|
||||
</span>
|
||||
</a-menu-item>
|
||||
</a-menu>
|
||||
</a-dropdown>
|
||||
</template>
|
||||
</a-table>
|
||||
</a-space>
|
||||
</template>
|
||||
<template v-else>
|
||||
<a-empty description='{{ i18n "emptyReverseDesc" }}' :style="{ margin: '10px' }">
|
||||
<a-button type="primary" icon="plus" @click="addReverse()" :style="{ marginTop: '10px' }">
|
||||
{{ i18n "pages.xray.outbound.addReverse" }}
|
||||
</a-button>
|
||||
</a-empty>
|
||||
</template>
|
||||
{{end}}
|
||||
@@ -81,13 +81,6 @@
|
||||
</template>
|
||||
{{ template "settings/xray/outbounds" . }}
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="tpl-reverse" :style="{ paddingTop: '20px' }" force-render="true">
|
||||
<template #tab>
|
||||
<a-icon type="import"></a-icon>
|
||||
<span>{{ i18n "pages.xray.outbound.reverse"}}</span>
|
||||
</template>
|
||||
{{ template "settings/xray/reverse" . }}
|
||||
</a-tab-pane>
|
||||
<a-tab-pane key="tpl-balancer" :style="{ paddingTop: '20px' }" force-render="true">
|
||||
<template #tab>
|
||||
<a-icon type="cluster"></a-icon>
|
||||
@@ -135,7 +128,6 @@
|
||||
{{template "component/aSettingListItem" .}}
|
||||
{{template "modals/ruleModal" .}}
|
||||
{{template "modals/outModal" .}}
|
||||
{{template "modals/reverseModal" .}}
|
||||
{{template "modals/balancerModal" .}}
|
||||
{{template "modals/dnsModal" .}}
|
||||
{{template "modals/dnsPresetsModal" .}}
|
||||
@@ -184,34 +176,6 @@
|
||||
{ title: '{{ i18n "pages.xray.outbound.test" }}', align: 'center', width: 70, scopedSlots: { customRender: 'test' } },
|
||||
];
|
||||
|
||||
const reverseColumns = [{
|
||||
title: "#",
|
||||
align: 'center',
|
||||
width: 20,
|
||||
scopedSlots: {
|
||||
customRender: 'action'
|
||||
}
|
||||
},
|
||||
{
|
||||
title: '{{ i18n "pages.xray.outbound.type"}}',
|
||||
dataIndex: 'type',
|
||||
align: 'center',
|
||||
width: 50
|
||||
},
|
||||
{
|
||||
title: '{{ i18n "pages.xray.outbound.tag"}}',
|
||||
dataIndex: 'tag',
|
||||
align: 'center',
|
||||
width: 50
|
||||
},
|
||||
{
|
||||
title: '{{ i18n "pages.xray.outbound.domain"}}',
|
||||
dataIndex: 'domain',
|
||||
align: 'center',
|
||||
width: 50
|
||||
},
|
||||
];
|
||||
|
||||
const balancerColumns = [{
|
||||
title: "#",
|
||||
align: 'center',
|
||||
@@ -945,110 +909,6 @@
|
||||
Vue.prototype.$message.error('{{ i18n "pages.xray.outbound.testError" }}: ' + error.message);
|
||||
}
|
||||
},
|
||||
addReverse() {
|
||||
reverseModal.show({
|
||||
title: '{{ i18n "pages.xray.outbound.addReverse"}}',
|
||||
okText: '{{ i18n "pages.xray.outbound.addReverse" }}',
|
||||
confirm: (reverse, rules) => {
|
||||
reverseModal.loading();
|
||||
if (reverse.tag.length > 0) {
|
||||
newTemplateSettings = this.templateSettings;
|
||||
if (newTemplateSettings.reverse == undefined) newTemplateSettings.reverse = {};
|
||||
if (newTemplateSettings.reverse[reverse.type + 's'] == undefined) newTemplateSettings.reverse[
|
||||
reverse.type + 's'] = [];
|
||||
newTemplateSettings.reverse[reverse.type + 's'].push({
|
||||
tag: reverse.tag,
|
||||
domain: reverse.domain
|
||||
});
|
||||
this.templateSettings = newTemplateSettings;
|
||||
|
||||
// Add related rules
|
||||
this.templateSettings.routing.rules.push(...rules);
|
||||
this.routingRuleSettings = JSON.stringify(this.templateSettings.routing.rules);
|
||||
}
|
||||
reverseModal.close();
|
||||
},
|
||||
isEdit: false
|
||||
});
|
||||
},
|
||||
editReverse(index) {
|
||||
if (this.reverseData[index].type == "bridge") {
|
||||
oldRules = this.templateSettings.routing.rules.filter(r => r.inboundTag && r.inboundTag[0] == this
|
||||
.reverseData[index].tag);
|
||||
} else {
|
||||
oldRules = this.templateSettings.routing.rules.filter(r => r.outboundTag && r.outboundTag == this
|
||||
.reverseData[index].tag);
|
||||
}
|
||||
reverseModal.show({
|
||||
title: '{{ i18n "pages.xray.outbound.editReverse"}} ' + (index + 1),
|
||||
reverse: this.reverseData[index],
|
||||
rules: oldRules,
|
||||
confirm: (reverse, rules) => {
|
||||
reverseModal.loading();
|
||||
if (reverse.tag.length > 0) {
|
||||
oldData = this.reverseData[index];
|
||||
newTemplateSettings = this.templateSettings;
|
||||
oldReverseIndex = newTemplateSettings.reverse[oldData.type + 's'].findIndex(rs => rs.tag ==
|
||||
oldData.tag);
|
||||
oldRuleIndex0 = oldRules.length > 0 ? newTemplateSettings.routing.rules.findIndex(r => JSON
|
||||
.stringify(r) == JSON.stringify(oldRules[0])) : -1;
|
||||
oldRuleIndex1 = oldRules.length == 2 ? newTemplateSettings.routing.rules.findIndex(r => JSON
|
||||
.stringify(r) == JSON.stringify(oldRules[1])) : -1;
|
||||
if (oldData.type == reverse.type) {
|
||||
newTemplateSettings.reverse[oldData.type + 's'][oldReverseIndex] = {
|
||||
tag: reverse.tag,
|
||||
domain: reverse.domain
|
||||
};
|
||||
} else {
|
||||
newTemplateSettings.reverse[oldData.type + 's'].splice(oldReverseIndex, 1);
|
||||
// delete empty object
|
||||
if (newTemplateSettings.reverse[oldData.type + 's'].length == 0) Reflect.deleteProperty(
|
||||
newTemplateSettings.reverse, oldData.type + 's');
|
||||
// add other type of reverse if it is not exist
|
||||
if (!newTemplateSettings.reverse[reverse.type + 's']) newTemplateSettings.reverse[reverse
|
||||
.type + 's'] = [];
|
||||
newTemplateSettings.reverse[reverse.type + 's'].push({
|
||||
tag: reverse.tag,
|
||||
domain: reverse.domain
|
||||
});
|
||||
}
|
||||
this.templateSettings = newTemplateSettings;
|
||||
|
||||
// Adjust Rules
|
||||
newRules = this.templateSettings.routing.rules;
|
||||
oldRuleIndex0 != -1 ? newRules[oldRuleIndex0] = rules[0] : newRules.push(rules[0]);
|
||||
oldRuleIndex1 != -1 ? newRules[oldRuleIndex1] = rules[1] : newRules.push(rules[1]);
|
||||
this.routingRuleSettings = JSON.stringify(newRules);
|
||||
}
|
||||
reverseModal.close();
|
||||
},
|
||||
isEdit: true
|
||||
});
|
||||
},
|
||||
deleteReverse(index) {
|
||||
oldData = this.reverseData[index];
|
||||
newTemplateSettings = this.templateSettings;
|
||||
reverseTypeObj = newTemplateSettings.reverse[oldData.type + 's'];
|
||||
realIndex = reverseTypeObj.findIndex(r => r.tag == oldData.tag && r.domain == oldData.domain);
|
||||
newTemplateSettings.reverse[oldData.type + 's'].splice(realIndex, 1);
|
||||
|
||||
// delete empty objects
|
||||
if (reverseTypeObj.length == 0) Reflect.deleteProperty(newTemplateSettings.reverse, oldData.type + 's');
|
||||
if (Object.keys(newTemplateSettings.reverse).length === 0) Reflect.deleteProperty(newTemplateSettings,
|
||||
'reverse');
|
||||
|
||||
// delete related routing rules
|
||||
newRules = newTemplateSettings.routing.rules;
|
||||
if (oldData.type == "bridge") {
|
||||
newRules = newTemplateSettings.routing.rules.filter(r => !(r.inboundTag && r.inboundTag.length == 1 && r
|
||||
.inboundTag[0] == oldData.tag));
|
||||
} else if (oldData.type == "portal") {
|
||||
newRules = newTemplateSettings.routing.rules.filter(r => r.outboundTag != oldData.tag);
|
||||
}
|
||||
newTemplateSettings.routing.rules = newRules;
|
||||
|
||||
this.templateSettings = newTemplateSettings;
|
||||
},
|
||||
async refreshOutboundTraffic() {
|
||||
if (!this.refreshing) {
|
||||
this.refreshing = true;
|
||||
@@ -1457,32 +1317,6 @@
|
||||
return data;
|
||||
},
|
||||
},
|
||||
reverseData: {
|
||||
get: function() {
|
||||
data = []
|
||||
if (this.templateSettings != null && this.templateSettings.reverse != null) {
|
||||
if (this.templateSettings.reverse.bridges) {
|
||||
this.templateSettings.reverse.bridges.forEach((o, index) => {
|
||||
data.push({
|
||||
'key': index,
|
||||
'type': 'bridge',
|
||||
...o
|
||||
});
|
||||
});
|
||||
}
|
||||
if (this.templateSettings.reverse.portals) {
|
||||
this.templateSettings.reverse.portals.forEach((o, index) => {
|
||||
data.push({
|
||||
'key': index,
|
||||
'type': 'portal',
|
||||
...o
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
return data;
|
||||
},
|
||||
},
|
||||
routingRuleSettings: {
|
||||
get: function() {
|
||||
return this.templateSettings ? JSON.stringify(this.templateSettings.routing.rules, null, 2) : null;
|
||||
|
||||
Reference in New Issue
Block a user