Browse Source

DNS - Expect IPs

mhsanaei 5 months ago
parent
commit
0b8beafc89

+ 26 - 7
web/html/xui/dns_modal.html

@@ -1,5 +1,7 @@
 {{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-item label='{{ i18n "pages.xray.outbound.address" }}'>
       <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>
       <template v-for="(domain, index) in dnsModal.dnsServer.domains">
         <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>
       </template>
     </a-form-item>
     <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>
     </a-form-item>
     <a-form-item label='Skip Fallback' v-if="isAdvanced">
       <a-switch v-model="dnsModal.dnsServer.skipFallback"></a-switch>
     </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-modal>
 <script>
@@ -32,20 +45,24 @@
     dnsServer: {
       address: "localhost",
       domains: [],
+      expectIPs: [],
       queryStrategy: 'UseIP',
       skipFallback: true,
     },
     ok() {
       domains = dnsModal.dnsServer.domains.filter(d => d.length > 0);
+      expectIPs = dnsModal.dnsServer.expectIPs.filter(ip => ip.length > 0);
       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);
     },
+
     show({
       title = '',
       okText = '{{ i18n "confirm" }}',
       dnsServer,
-      confirm = (dnsServer) => {},
+      confirm = (dnsServer) => { },
       isEdit = false
     }) {
       this.title = title;
@@ -59,6 +76,7 @@
           this.dnsServer = {
             address: dnsServer ?? "",
             domains: [],
+            expectIPs: [],
             queryStrategy: 'UseIP',
             skipFallback: true,
           }
@@ -67,6 +85,7 @@
         this.dnsServer = {
           address: "localhost",
           domains: [],
+          expectIPs: [],
           queryStrategy: 'UseIP',
           skipFallback: true,
         }
@@ -85,8 +104,8 @@
     },
     computed: {
       isAdvanced: {
-        get: function() {
-          return dnsModal.dnsServer.domains.length > 0
+        get: function () {
+          return dnsModal.dnsServer.domains.length > 0;
         }
       }
     }

+ 83 - 78
web/html/xui/xray.html

@@ -587,86 +587,90 @@
                 </a-radio-group>
                 <textarea style="position:absolute; left: -800px;" id="obsSetting"></textarea>
               </a-tab-pane>
-              <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>
+            <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>
                 <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>
-                  <a-list-item style="padding: 10px 20px">
-                    <a-row>
-                      <a-col :lg="24" :xl="12">
-                        <a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}' description='{{ i18n "pages.xray.dns.strategyDesc" }}' />
-                      </a-col>
-                      <a-col :lg="24" :xl="12">
-                        <a-select
-                            v-model="dnsStrategy"
-                            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>
-                      </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"
-                      :data-source="dnsServers"
-                      :scroll="isMobile ? {} : { x: 200 }"
-                      :pagination="false"
-                      :indent-size="0"
-                      :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
-                    <template slot="action" slot-scope="text,dns,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="editDNSServer(index)">
-                            <a-icon type="edit"></a-icon>
-                            {{ i18n "edit" }}
-                          </a-menu-item>
-                          <a-menu-item @click="deleteDNSServer(index)">
-                            <span style="color: #FF4D4F">
-                              <a-icon type="delete"></a-icon> {{ i18n "delete"}}
-                            </span>
-                          </a-menu-item>
-                        </a-menu>
-                      </a-dropdown>
-                    </template>
-                    <template slot="address" slot-scope="dns,index">
-                      <span v-if="typeof dns == 'object'">[[ dns.address ]]</span>
-                      <span v-else>[[ dns ]]</span>
-                    </template>
-                    <template slot="domain" slot-scope="dns,index">
-                      <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>
+                    <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>
+                    <a-list-item style="padding: 10px 20px">
+                        <a-row>
+                            <a-col :lg="24" :xl="12">
+                                <a-list-item-meta title='{{ i18n "pages.xray.dns.strategy" }}'
+                                    description='{{ i18n "pages.xray.dns.strategyDesc" }}' />
+                            </a-col>
+                            <a-col :lg="24" :xl="12">
+                                <a-select v-model="dnsStrategy" 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>
+                            </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"
+                        :data-source="dnsServers" :scroll="isMobile ? {} : { x: 200 }" :pagination="false" :indent-size="0"
+                        :style="isMobile ? 'padding: 5px 0' : 'margin-left: 1px;'">
+                        <template slot="action" slot-scope="text,dns,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="editDNSServer(index)">
+                                        <a-icon type="edit"></a-icon>
+                                        {{ i18n "edit" }}
+                                    </a-menu-item>
+                                    <a-menu-item @click="deleteDNSServer(index)">
+                                        <span style="color: #FF4D4F">
+                                            <a-icon type="delete"></a-icon> {{ i18n "delete"}}
+                                        </span>
+                                    </a-menu-item>
+                                </a-menu>
+                            </a-dropdown>
+                        </template>
+                        <template slot="address" slot-scope="dns,index">
+                            <span v-if="typeof dns == 'object'">[[ dns.address ]]</span>
+                            <span v-else>[[ dns ]]</span>
+                        </template>
+                        <template slot="domain" slot-scope="dns,index">
+                            <span v-if="typeof dns == 'object'">[[ dns.domains.join(",") ]]</span>
+                        </template>
+                        <template slot="expectIPs" slot-scope="dns,index">
+                            <span v-if="typeof dns == 'object'">[[ dns.expectIPs.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>
               <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-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: '{{ 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.expectIPs"}}', align: 'center', width: 50, scopedSlots: { customRender: 'expectIPs' } },
     ];
 
     const fakednsColumns = [

+ 1 - 0
web/translation/translate.en_US.toml

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

+ 1 - 0
web/translation/translate.es_ES.toml

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

+ 1 - 0
web/translation/translate.fa_IR.toml

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

+ 1 - 0
web/translation/translate.id_ID.toml

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

+ 1 - 0
web/translation/translate.pt_BR.toml

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

+ 1 - 0
web/translation/translate.ru_RU.toml

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

+ 1 - 0
web/translation/translate.tr_TR.toml

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

+ 1 - 0
web/translation/translate.uk_UA.toml

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

+ 1 - 0
web/translation/translate.vi_VN.toml

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

+ 1 - 0
web/translation/translate.zh_CN.toml

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