[xray] fakedns support

This commit is contained in:
Alireza Ahmadi
2024-02-20 14:05:53 +01:00
parent 08403bc8f9
commit f8d20c8303
7 changed files with 160 additions and 0 deletions

View File

@@ -0,0 +1,57 @@
{{define "fakednsModal"}}
<a-modal id="fakedns-modal" v-model="fakednsModal.visible" :title="fakednsModal.title" @ok="fakednsModal.ok"
:closable="true" :mask-closable="false"
:ok-text="fakednsModal.okText" cancel-text='{{ i18n "close" }}' :class="themeSwitcher.currentTheme">
<a-form :colon="false" :label-col="{ md: {span:6} }" :wrapper-col="{ md: {span:14} }">
<a-form-item label='{{ i18n "pages.xray.fakedns.ipPool" }}'>
<a-input v-model.trim="fakednsModal.fakeDns.ipPool"></a-input>
</a-form-item>
<a-form-item label='{{ i18n "pages.xray.fakedns.poolSize" }}'>
<a-input type="number" min="1" v-model.trim="fakednsModal.fakeDns.poolSize"></a-input>
</a-form-item>
</a-form>
</a-modal>
<script>
const fakednsModal = {
title: '',
visible: false,
okText: '{{ i18n "confirm" }}',
isEdit: false,
confirm: null,
fakeDns: {
ipPool: "198.18.0.0/16",
poolSize: 65535,
},
ok() {
ObjectUtil.execute(fakednsModal.confirm, fakednsModal.fakeDns);
},
show({ title='', okText='{{ i18n "confirm" }}', fakeDns, confirm=(fakeDns)=>{}, isEdit=false }) {
this.title = title;
this.okText = okText;
this.confirm = confirm;
this.visible = true;
if(isEdit) {
this.fakeDns = fakeDns;
} else {
this.fakeDns = {
ipPool: "198.18.0.0/16",
poolSize: 65535,
}
}
this.isEdit = isEdit;
},
close() {
fakednsModal.visible = false;
},
};
new Vue({
delimiters: ['[[', ']]'],
el: '#fakedns-modal',
data: {
fakednsModal: fakednsModal,
}
});
</script>
{{end}}

View File

@@ -523,6 +523,7 @@
</a-col>
</a-row>
</a-list-item>
<a-divider>DNS</a-divider>
<a-button type="primary" icon="plus" @click="addDNSServer()" style="margin-bottom: 10px;">{{ i18n "pages.xray.dns.add" }}</a-button>
<a-table :columns="dnsColumns" bordered v-if="dnsServers.length>0"
:row-key="r => r.key"
@@ -556,6 +557,33 @@
<span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span>
</template>
</a-table>
<a-divider>Fake DNS</a-divider>
<a-button type="primary" icon="plus" @click="addFakedns()" style="margin-bottom: 10px;">{{ i18n "pages.xray.fakedns.add" }}</a-button>
<a-table :columns="fakednsColumns" bordered v-if="fakeDns && fakeDns.length>0"
:row-key="r => r.key"
:data-source="fakeDns"
:scroll="isMobile ? {} : { x: 200 }"
:pagination="false"
:indent-size="0"
:style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
<template slot="action" slot-scope="text,fakedns,index">
[[ index+1 ]]
<a-dropdown :trigger="['click']">
<a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon>
<a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
<a-menu-item @click="editFakedns(index)">
<a-icon type="edit"></a-icon>
{{ i18n "edit" }}
</a-menu-item>
<a-menu-item @click="deleteFakedns(index)">
<span style="color: #FF4D4F">
<a-icon type="delete"></a-icon> {{ i18n "delete"}}
</span>
</a-menu-item>
</a-menu>
</a-dropdown>
</template>
</a-table>
</template>
</a-tab-pane>
<a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
@@ -582,6 +610,7 @@
{{template "reverseModal"}}
{{template "balancerModal"}}
{{template "dnsModal"}}
{{template "fakednsModal"}}
{{template "warpModal"}}
<script>
const rulesColumns = [
@@ -638,6 +667,12 @@
{ title: '{{ i18n "pages.xray.dns.domains"}}', align: 'center', width: 50, scopedSlots: { customRender: 'domain' } },
];
const fakednsColumns = [
{ title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
{ title: '{{ i18n "pages.xray.fakedns.ipPool"}}', dataIndex: 'ipPool', align: 'center', width: 50 },
{ title: '{{ i18n "pages.xray.fakedns.poolSize"}}', dataIndex: 'poolSize', align: 'center', width: 50 },
];
const app = new Vue({
delimiters: ['[[', ']]'],
el: '#app',
@@ -1139,6 +1174,36 @@
newDnsServers.splice(index,1);
this.dnsServers = newDnsServers;
},
addFakedns() {
fakednsModal.show({
title: '{{ i18n "pages.xray.fakedns.add" }}',
confirm: (item) => {
fakeDns = this.fakeDns?? [];
fakeDns.push(item);
this.fakeDns = fakeDns;
fakednsModal.close();
},
isEdit: false
});
},
editFakedns(index){
fakednsModal.show({
title: '{{ i18n "pages.xray.fakedns.edit" }} #' + (index+1),
fakeDns: this.fakeDns[index],
confirm: (item) => {
fakeDns = this.fakeDns;
fakeDns[index] = item;
this.fakeDns = fakeDns;
fakednsModal.close();
},
isEdit: true
});
},
deleteFakedns(index){
fakeDns = this.fakeDns;
fakeDns.splice(index,1);
this.fakeDns = fakeDns;
},
addRule(){
ruleModal.show({
title: '{{ i18n "pages.xray.rules.add"}}',
@@ -1729,6 +1794,14 @@
newTemplateSettings.dns.servers = newValue;
this.templateSettings = newTemplateSettings;
}
},
fakeDns: {
get: function () { return this.templateSettings && this.templateSettings.fakedns ? this.templateSettings.fakedns : []; },
set: function (newValue) {
newTemplateSettings = this.templateSettings;
newTemplateSettings.fakedns = newValue.length >0 ? newValue : null;
this.templateSettings = newTemplateSettings;
}
}
},
});

View File

@@ -442,6 +442,12 @@
"edit" = "Edit Server"
"domains" = "Domains"
[pages.xray.fakedns]
"add" = "Add Fake DNS"
"edit" = "Edit Fake DNS"
"ipPool" = "IP Pool Subnet"
"poolSize" = "Pool Size"
[tgbot]
"noResult" = "❗ No result!"
"wentWrong" = "❌ Something went wrong!"

View File

@@ -441,6 +441,12 @@
"edit" = "ویرایش سرور"
"domains" = "دامنه‌ها"
[pages.xray.fakedns]
"add" = "افزودن دی‌ان‌اس جعلی"
"edit" = "ویرایش دی‌ان‌اس جعلی"
"ipPool" = "زیرشبکه استخر آی‌پی"
"poolSize" = "اندازه استخر"
[tgbot]
"noResult" = "❗نتیجه‌ای یافت نشد"
"wentWrong" = "❌ مشکلی رخ داده‌است"

View File

@@ -442,6 +442,12 @@
"edit" = "Редактировать сервер"
"domains" = "Домены"
[pages.xray.fakedns]
"add" = "Добавить поддельный DNS"
"edit" = "Редактировать поддельный DNS"
"ipPool" = "Подсеть пула IP"
"poolSize" = "Размер пула"
[tgbot]
"noResult" = "❗ Нет результатов!"
"wentWrong" = "❌ Что-то пошло не так!"

View File

@@ -442,6 +442,12 @@
"edit" = "Chỉnh sửa máy chủ"
"domains" = "Tên miền"
[pages.xray.fakedns]
"add" = "Thêm DNS giả"
"edit" = "Chỉnh sửa DNS giả"
"ipPool" = "Mạng con nhóm IP"
"poolSize" = "Kích thước bể bơi"
[tgbot]
"noResult" = "❗ Không có kết quả!"
"wentWrong" = "❌ Đã xảy ra lỗi!"

View File

@@ -442,6 +442,12 @@
"edit" = "编辑服务器"
"domains" = "域"
[pages.xray.fakedns]
"add" = "添加假 DNS"
"edit" = "编辑假 DNS"
"ipPool" = "IP 池子网"
"poolSize" = "池大小"
[tgbot]
"noResult" = "❗ 没有结果!"
"wentWrong" = "❌ 出了点问题!"