Browse Source

[xray] fakedns support

Co-Authored-By: Alireza Ahmadi <[email protected]>
MHSanaei 1 year ago
parent
commit
7708bb9af2

+ 57 - 0
web/html/xui/fakedns_modal.html

@@ -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}}

+ 72 - 1
web/html/xui/xray.html

@@ -523,7 +523,7 @@
                                 </template>
                             </a-table>                            
                         </a-tab-pane>
-                        <a-tab-pane key="tpl-5" tab='DNS' style="padding-top: 20px;" force-render="true">
+                        <a-tab-pane key="tpl-6" 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">
                                 <a-list-item>
@@ -543,6 +543,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"
@@ -576,6 +577,30 @@
                                         <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">
@@ -601,6 +626,8 @@
 {{template "outModal"}}
 {{template "reverseModal"}}
 {{template "balancerModal"}}
+{{template "dnsModal"}}
+{{template "fakednsModal"}}
 {{template "warpModal"}}
 <script>
         const rulesColumns = [
@@ -651,6 +678,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 balancerColumns = [
         { title: "#", align: 'center', width: 20, scopedSlots: { customRender: 'action' } },
         { title: '{{ i18n "pages.xray.balancer.tag"}}', dataIndex: 'tag', align: 'center', width: 50 },
@@ -1257,6 +1290,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"}}',
@@ -1909,6 +1972,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;
+                }
             }
         },
     });

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

@@ -463,6 +463,12 @@
 "edit" = "Edit Server"
 "domains" = "Domains"
 
+[pages.xray.fakedns]
+"add" = "Add Fake DNS"
+"edit" = "Edit Fake DNS"
+"ipPool" = "IP Pool Subnet"
+"poolSize" = "Pool Size"
+
 [pages.settings.security]
 "admin" = "Admin"
 "secret" = "Secret Token"

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

@@ -463,6 +463,12 @@
 "edit" = "Editar servidor"
 "domains" = "Dominios"
 
+[pages.xray.fakedns]
+"add" = "Agregar DNS falso"
+"edit" = "Editar DNS falso"
+"ipPool" = "Subred del grupo de IP"
+"poolSize" = "Tamaño del grupo"
+
 [pages.settings.security]
 "admin" = "Administrador"
 "secret" = "Token Secreto"

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

@@ -463,6 +463,12 @@
 "edit" = "ویرایش سرور"
 "domains" = "دامنه‌ها"
 
+[pages.xray.fakedns]
+"add" = "افزودن دی‌ان‌اس جعلی"
+"edit" = "ویرایش دی‌ان‌اس جعلی"
+"ipPool" = "زیرشبکه استخر آی‌پی"
+"poolSize" = "اندازه استخر"
+
 [pages.settings.security]
 "admin" = "مدیر"
 "secret" = "توکن مخفی"

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

@@ -463,6 +463,12 @@
 "edit" = "Sunting Server"
 "domains" = "Domains"
 
+[pages.xray.fakedns]
+"add" = "Tambahkan DNS Palsu"
+"edit" = "Edit DNS Palsu"
+"ipPool" = "Subnet Kumpulan IP"
+"poolSize" = "Ukuran Kolam"
+
 [pages.settings.security]
 "admin" = "Admin"
 "secret" = "Token Rahasia"

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

@@ -463,6 +463,12 @@
 "edit" = "Редактировать сервер"
 "domains" = "Домены"
 
+[pages.xray.fakedns]
+"add" = "Добавить поддельный DNS"
+"edit" = "Редактировать поддельный DNS"
+"ipPool" = "Подсеть пула IP"
+"poolSize" = "Размер пула"
+
 [pages.settings.security]
 "admin" = "Админ"
 "secret" = "Секретный токен"

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

@@ -463,6 +463,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"
+
 [pages.settings.security]
 "admin" = "Quản trị viên"
 "secret" = "Mã thông báo bí mật"

+ 6 - 0
web/translation/translate.zh_Hans.toml

@@ -463,6 +463,12 @@
 "edit" = "编辑服务器"
 "domains" = "域"
 
+[pages.xray.fakedns]
+"add" = "添加假 DNS"
+"edit" = "编辑假 DNS"
+"ipPool" = "IP 池子网"
+"poolSize" = "池大小"
+
 [pages.settings.security]
 "admin" = "管理员"
 "secret" = "密钥"