DNS - Expect IPs

This commit is contained in:
mhsanaei 2024-09-26 13:08:54 +02:00
parent 8b6e3491c4
commit 0b8beafc89
No known key found for this signature in database
GPG key ID: 4DACC0663B5986F5
12 changed files with 119 additions and 85 deletions

View file

@ -1,5 +1,7 @@
{{define "dnsModal"}} {{define "dnsModal"}}
<a-modal id="dns-modal" v-model="dnsModal.visible" :title="dnsModal.title" @ok="dnsModal.ok" :closable="true" :mask-closable="false" :ok-text="dnsModal.okText" cancel-text='{{ i18n "close" }}' :class="themeSwitcher.currentTheme"> <a-modal id="dns-modal" v-model="dnsModal.visible" :title="dnsModal.title" @ok="dnsModal.ok" :closable="true"
:mask-closable="false" :ok-text="dnsModal.okText" cancel-text='{{ i18n "close" }}'
:class="themeSwitcher.currentTheme">
<a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }"> <a-form :colon="false" :label-col="{ md: {span:8} }" :wrapper-col="{ md: {span:14} }">
<a-form-item label='{{ i18n "pages.xray.outbound.address" }}'> <a-form-item label='{{ i18n "pages.xray.outbound.address" }}'>
<a-input v-model.trim="dnsModal.dnsServer.address"></a-input> <a-input v-model.trim="dnsModal.dnsServer.address"></a-input>
@ -8,18 +10,29 @@
<a-button icon="plus" size="small" type="primary" @click="dnsModal.dnsServer.domains.push('')"></a-button> <a-button icon="plus" size="small" type="primary" @click="dnsModal.dnsServer.domains.push('')"></a-button>
<template v-for="(domain, index) in dnsModal.dnsServer.domains"> <template v-for="(domain, index) in dnsModal.dnsServer.domains">
<a-input v-model.trim="dnsModal.dnsServer.domains[index]"> <a-input v-model.trim="dnsModal.dnsServer.domains[index]">
<a-button icon="minus" size="small" slot="addonAfter" @click="dnsModal.dnsServer.domains.splice(index,1)"></a-button> <a-button icon="minus" size="small" slot="addonAfter"
@click="dnsModal.dnsServer.domains.splice(index,1)"></a-button>
</a-input> </a-input>
</template> </template>
</a-form-item> </a-form-item>
<a-form-item label='{{ i18n "pages.xray.dns.strategy" }}' v-if="isAdvanced"> <a-form-item label='{{ i18n "pages.xray.dns.strategy" }}' v-if="isAdvanced">
<a-select v-model="dnsModal.dnsServer.queryStrategy" style="width: 100%" :dropdown-class-name="themeSwitcher.currentTheme"> <a-select v-model="dnsModal.dnsServer.queryStrategy" style="width: 100%"
:dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']"> [[ l ]] </a-select-option> <a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']"> [[ l ]] </a-select-option>
</a-select> </a-select>
</a-form-item> </a-form-item>
<a-form-item label='Skip Fallback' v-if="isAdvanced"> <a-form-item label='Skip Fallback' v-if="isAdvanced">
<a-switch v-model="dnsModal.dnsServer.skipFallback"></a-switch> <a-switch v-model="dnsModal.dnsServer.skipFallback"></a-switch>
</a-form-item> </a-form-item>
<a-form-item label='{{ i18n "pages.xray.dns.expectIPs"}}'>
<a-button icon="plus" size="small" type="primary" @click="dnsModal.dnsServer.expectIPs.push('')"></a-button>
<template v-for="(domain, index) in dnsModal.dnsServer.expectIPs">
<a-input v-model.trim="dnsModal.dnsServer.expectIPs[index]">
<a-button icon="minus" size="small" slot="addonAfter"
@click="dnsModal.dnsServer.expectIPs.splice(index,1)"></a-button>
</a-input>
</template>
</a-form-item>
</a-form> </a-form>
</a-modal> </a-modal>
<script> <script>
@ -32,20 +45,24 @@
dnsServer: { dnsServer: {
address: "localhost", address: "localhost",
domains: [], domains: [],
expectIPs: [],
queryStrategy: 'UseIP', queryStrategy: 'UseIP',
skipFallback: true, skipFallback: true,
}, },
ok() { ok() {
domains = dnsModal.dnsServer.domains.filter(d => d.length > 0); domains = dnsModal.dnsServer.domains.filter(d => d.length > 0);
expectIPs = dnsModal.dnsServer.expectIPs.filter(ip => ip.length > 0);
dnsModal.dnsServer.domains = domains; dnsModal.dnsServer.domains = domains;
newDnsServer = domains.length > 0 ? dnsModal.dnsServer : dnsModal.dnsServer.address; dnsModal.dnsServer.expectIPs = expectIPs;
newDnsServer = (domains.length > 0 || expectIPs.length > 0) ? dnsModal.dnsServer : dnsModal.dnsServer.address;
ObjectUtil.execute(dnsModal.confirm, newDnsServer); ObjectUtil.execute(dnsModal.confirm, newDnsServer);
}, },
show({ show({
title = '', title = '',
okText = '{{ i18n "confirm" }}', okText = '{{ i18n "confirm" }}',
dnsServer, dnsServer,
confirm = (dnsServer) => {}, confirm = (dnsServer) => { },
isEdit = false isEdit = false
}) { }) {
this.title = title; this.title = title;
@ -59,6 +76,7 @@
this.dnsServer = { this.dnsServer = {
address: dnsServer ?? "", address: dnsServer ?? "",
domains: [], domains: [],
expectIPs: [],
queryStrategy: 'UseIP', queryStrategy: 'UseIP',
skipFallback: true, skipFallback: true,
} }
@ -67,6 +85,7 @@
this.dnsServer = { this.dnsServer = {
address: "localhost", address: "localhost",
domains: [], domains: [],
expectIPs: [],
queryStrategy: 'UseIP', queryStrategy: 'UseIP',
skipFallback: true, skipFallback: true,
} }
@ -85,8 +104,8 @@
}, },
computed: { computed: {
isAdvanced: { isAdvanced: {
get: function() { get: function () {
return dnsModal.dnsServer.domains.length > 0 return dnsModal.dnsServer.domains.length > 0;
} }
} }
} }

View file

@ -587,86 +587,90 @@
</a-radio-group> </a-radio-group>
<textarea style="position:absolute; left: -800px;" id="obsSetting"></textarea> <textarea style="position:absolute; left: -800px;" id="obsSetting"></textarea>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="tpl-dns" tab='DNS' style="padding-top: 20px;" force-render="true"> <a-tab-pane key="tpl-dns" tab='DNS' style="padding-top: 20px;" force-render="true">
<setting-list-item type="switch" title='{{ i18n "pages.xray.dns.enable" }}' desc='{{ i18n "pages.xray.dns.enableDesc" }}' v-model="enableDNS"></setting-list-item> <setting-list-item type="switch" title='{{ i18n "pages.xray.dns.enable" }}'
desc='{{ i18n "pages.xray.dns.enableDesc" }}' v-model="enableDNS"></setting-list-item>
<template v-if="enableDNS"> <template v-if="enableDNS">
<setting-list-item style="padding: 10px 20px" type="text" title='{{ i18n "pages.xray.dns.tag" }}' desc='{{ i18n "pages.xray.dns.tagDesc" }}' v-model="dnsTag"></setting-list-item> <setting-list-item style="padding: 10px 20px" type="text" title='{{ i18n "pages.xray.dns.tag" }}'
<a-list-item style="padding: 10px 20px"> desc='{{ i18n "pages.xray.dns.tagDesc" }}' v-model="dnsTag"></setting-list-item>
<a-row> <a-list-item style="padding: 10px 20px">
<a-col :lg="24" :xl="12"> <a-row>
<a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}' description='{{ i18n "pages.xray.dns.strategyDesc" }}' /> <a-col :lg="24" :xl="12">
</a-col> <a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}'
<a-col :lg="24" :xl="12"> description='{{ i18n "pages.xray.dns.strategyDesc" }}' />
<a-select </a-col>
v-model="dnsStrategy" <a-col :lg="24" :xl="12">
style="width: 100%" <a-select v-model="dnsStrategy" style="width: 100%"
:dropdown-class-name="themeSwitcher.currentTheme"> :dropdown-class-name="themeSwitcher.currentTheme">
<a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']"> <a-select-option :value="l" :label="l" v-for="l in ['UseIP', 'UseIPv4', 'UseIPv6']">
[[ l ]] [[ l ]]
</a-select-option> </a-select-option>
</a-select> </a-select>
</a-col> </a-col>
</a-row> </a-row>
</a-list-item> </a-list-item>
<a-divider>DNS</a-divider> <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-button type="primary" icon="plus" @click="addDNSServer()" style="margin-bottom: 10px;">{{ i18n
<a-table :columns="dnsColumns" bordered v-if="dnsServers.length>0" "pages.xray.dns.add" }}</a-button>
:row-key="r => r.key" <a-table :columns="dnsColumns" bordered v-if="dnsServers.length>0" :row-key="r => r.key"
:data-source="dnsServers" :data-source="dnsServers" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
:scroll="isMobile ? {} : { x: 200 }" :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
:pagination="false" <template slot="action" slot-scope="text,dns,index">
:indent-size="0" [[ index+1 ]]
:style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'"> <a-dropdown :trigger="['click']">
<template slot="action" slot-scope="text,dns,index"> <a-icon @click="e => e.preventDefault()" type="more"
[[ index+1 ]] style="font-size: 16px; text-decoration: bold;"></a-icon>
<a-dropdown :trigger="['click']"> <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
<a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon> <a-menu-item @click="editDNSServer(index)">
<a-menu slot="overlay" :theme="themeSwitcher.currentTheme"> <a-icon type="edit"></a-icon>
<a-menu-item @click="editDNSServer(index)"> {{ i18n "edit" }}
<a-icon type="edit"></a-icon> </a-menu-item>
{{ i18n "edit" }} <a-menu-item @click="deleteDNSServer(index)">
</a-menu-item> <span style="color: #FF4D4F">
<a-menu-item @click="deleteDNSServer(index)"> <a-icon type="delete"></a-icon> {{ i18n "delete"}}
<span style="color: #FF4D4F"> </span>
<a-icon type="delete"></a-icon> {{ i18n "delete"}} </a-menu-item>
</span> </a-menu>
</a-menu-item> </a-dropdown>
</a-menu> </template>
</a-dropdown> <template slot="address" slot-scope="dns,index">
</template> <span v-if="typeof dns == 'object'">[[ dns.address ]]</span>
<template slot="address" slot-scope="dns,index"> <span v-else>[[ dns ]]</span>
<span v-if="typeof dns == 'object'">[[ dns.address ]]</span> </template>
<span v-else>[[ dns ]]</span> <template slot="domain" slot-scope="dns,index">
</template> <span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span>
<template slot="domain" slot-scope="dns,index"> </template>
<span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span> <template slot="expectIPs" slot-scope="dns,index">
</template> <span v-if="typeof dns == 'object'">[[ dns.expectIPs.join(",") ]]</span>
</a-table> </template>
<a-divider>Fake DNS</a-divider> </a-table>
<a-button type="primary" icon="plus" @click="addFakedns()" style="margin-bottom: 10px;">{{ i18n "pages.xray.fakedns.add" }}</a-button> <a-divider>Fake DNS</a-divider>
<a-table :columns="fakednsColumns" bordered v-if="fakeDns && fakeDns.length>0" :row-key="r => r.key" <a-button type="primary" icon="plus" @click="addFakedns()" style="margin-bottom: 10px;">{{ i18n
:data-source="fakeDns" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0" "pages.xray.fakedns.add" }}</a-button>
:style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'"> <a-table :columns="fakednsColumns" bordered v-if="fakeDns && fakeDns.length>0" :row-key="r => r.key"
<template slot="action" slot-scope="text,fakedns,index"> :data-source="fakeDns" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
[[ index+1 ]] :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
<a-dropdown :trigger="['click']"> <template slot="action" slot-scope="text,fakedns,index">
<a-icon @click="e => e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"></a-icon> [[ index+1 ]]
<a-menu slot="overlay" :theme="themeSwitcher.currentTheme"> <a-dropdown :trigger="['click']">
<a-menu-item @click="editFakedns(index)"> <a-icon @click="e => e.preventDefault()" type="more"
<a-icon type="edit"></a-icon> style="font-size: 16px; text-decoration: bold;"></a-icon>
{{ i18n "edit" }} <a-menu slot="overlay" :theme="themeSwitcher.currentTheme">
</a-menu-item> <a-menu-item @click="editFakedns(index)">
<a-menu-item @click="deleteFakedns(index)"> <a-icon type="edit"></a-icon>
<span style="color: #FF4D4F"> {{ i18n "edit" }}
<a-icon type="delete"></a-icon> {{ i18n "delete"}} </a-menu-item>
</span> <a-menu-item @click="deleteFakedns(index)">
</a-menu-item> <span style="color: #FF4D4F">
</a-menu> <a-icon type="delete"></a-icon> {{ i18n "delete"}}
</a-dropdown> </span>
</template> </a-menu-item>
</a-table> </a-menu>
</a-dropdown>
</template>
</a-table>
</template> </template>
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true"> <a-tab-pane key="tpl-advanced" tab='{{ i18n "pages.xray.advancedTemplate"}}' style="padding-top: 20px;" force-render="true">
<a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta> <a-list-item-meta title='{{ i18n "pages.xray.Template"}}' description='{{ i18n "pages.xray.TemplateDesc"}}'></a-list-item-meta>
<a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''"> <a-radio-group v-model="advSettings" @change="changeCode" button-style="solid" style="margin: 10px 0;" :size="isMobile ? 'small' : ''">
@ -748,6 +752,7 @@
{ title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } }, { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
{ title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } }, { title: '{{ i18n "pages.xray.outbound.address"}}', align: 'center', width: 50, scopedSlots: { customRender: 'address' } },
{ title: '{{ i18n "pages.xray.dns.domains"}}', align: 'center', width: 50, scopedSlots: { customRender: 'domain' } }, { title: '{{ i18n "pages.xray.dns.domains"}}', align: 'center', width: 50, scopedSlots: { customRender: 'domain' } },
{ title: '{{ i18n "pages.xray.dns.expectIPs"}}', align: 'center', width: 50, scopedSlots: { customRender: 'expectIPs' } },
]; ];
const fakednsColumns = [ const fakednsColumns = [

View file

@ -488,6 +488,7 @@
"add" = "Add Server" "add" = "Add Server"
"edit" = "Edit Server" "edit" = "Edit Server"
"domains" = "Domains" "domains" = "Domains"
"expectIPs" = "Expect IPs"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Add Fake DNS" "add" = "Add Fake DNS"

View file

@ -486,6 +486,7 @@
"add" = "Agregar Servidor" "add" = "Agregar Servidor"
"edit" = "Editar Servidor" "edit" = "Editar Servidor"
"domains" = "Dominios" "domains" = "Dominios"
"expectIPs" = "IPs esperadas"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Agregar DNS Falso" "add" = "Agregar DNS Falso"

View file

@ -488,6 +488,7 @@
"add" = "افزودن سرور" "add" = "افزودن سرور"
"edit" = "ویرایش سرور" "edit" = "ویرایش سرور"
"domains" = "دامنه‌ها" "domains" = "دامنه‌ها"
"expectIPs" = "آی‌پی‌های مورد انتظار"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "افزودن دی‌ان‌اس جعلی" "add" = "افزودن دی‌ان‌اس جعلی"

View file

@ -488,6 +488,7 @@
"add" = "Tambahkan Server" "add" = "Tambahkan Server"
"edit" = "Sunting Server" "edit" = "Sunting Server"
"domains" = "Domains" "domains" = "Domains"
"expectIPs" = "IP yang Diharapkan"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Tambahkan DNS Palsu" "add" = "Tambahkan DNS Palsu"

View file

@ -488,6 +488,7 @@
"add" = "Adicionar Servidor" "add" = "Adicionar Servidor"
"edit" = "Editar Servidor" "edit" = "Editar Servidor"
"domains" = "Domínios" "domains" = "Domínios"
"expectIPs" = "IPs Esperadas"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Adicionar Fake DNS" "add" = "Adicionar Fake DNS"

View file

@ -488,6 +488,7 @@
"add" = "Добавить сервер" "add" = "Добавить сервер"
"edit" = "Редактировать сервер" "edit" = "Редактировать сервер"
"domains" = "Домены" "domains" = "Домены"
"expectIPs" = "Ожидаемые IP"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Добавить поддельный DNS" "add" = "Добавить поддельный DNS"

View file

@ -488,6 +488,7 @@
"add" = "Sunucu Ekle" "add" = "Sunucu Ekle"
"edit" = "Sunucuyu Düzenle" "edit" = "Sunucuyu Düzenle"
"domains" = "Alan Adları" "domains" = "Alan Adları"
"expectIPs" = "Beklenen IP'ler"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Sahte DNS Ekle" "add" = "Sahte DNS Ekle"

View file

@ -488,6 +488,7 @@
"add" = "Додати сервер" "add" = "Додати сервер"
"edit" = "Редагувати сервер" "edit" = "Редагувати сервер"
"domains" = "Домени" "domains" = "Домени"
"expectIPs" = "Очікувані IP"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Додати підроблений DNS" "add" = "Додати підроблений DNS"

View file

@ -488,6 +488,7 @@
"add" = "Thêm máy chủ" "add" = "Thêm máy chủ"
"edit" = "Chỉnh sửa máy chủ" "edit" = "Chỉnh sửa máy chủ"
"domains" = "Tên miền" "domains" = "Tên miền"
"expectIPs" = "Các IP Dự Kiến"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "Thêm DNS giả" "add" = "Thêm DNS giả"

View file

@ -488,6 +488,7 @@
"add" = "添加服务器" "add" = "添加服务器"
"edit" = "编辑服务器" "edit" = "编辑服务器"
"domains" = "域" "domains" = "域"
"expectIPs" = "预期 IP"
[pages.xray.fakedns] [pages.xray.fakedns]
"add" = "添加假 DNS" "add" = "添加假 DNS"