Xray settings: Lua script for DNS and routing, DNS server id

This commit is contained in:
Alireza Ahmadi 2026-10-10 23:00:18 +02:00
parent 5a7f31651b
commit ccb92c70bf
7 changed files with 63 additions and 2 deletions

View file

@ -3,6 +3,17 @@
: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>
<template slot="label">
<a-tooltip>
<template slot="title">
<span>{{ i18n "pages.xray.dns.idDesc" }}</span>
</template>
ID <a-icon type="question-circle"></a-icon>
</a-tooltip>
</template>
<a-input v-model.trim="dnsModal.dnsServer.id"></a-input>
</a-form-item>
<a-form-item label='{{ i18n "address" }}'>
<a-input v-model.trim="dnsModal.dnsServer.address"></a-input>
</a-form-item>
@ -43,6 +54,7 @@
isEdit: false,
confirm: null,
dnsServer: {
id: '',
address: "localhost",
domains: [],
expectIPs: [],
@ -54,7 +66,9 @@
expectIPs = dnsModal.dnsServer.expectIPs.filter(ip => ip.length > 0);
dnsModal.dnsServer.domains = domains;
dnsModal.dnsServer.expectIPs = expectIPs;
newDnsServer = (domains.length > 0 || expectIPs.length > 0) ? dnsModal.dnsServer : dnsModal.dnsServer.address;
if (!dnsModal.dnsServer.id) delete dnsModal.dnsServer.id;
// a bare address string cannot carry the id a DNS script looks servers up by
newDnsServer = (domains.length > 0 || expectIPs.length > 0 || dnsModal.dnsServer.id) ? dnsModal.dnsServer : dnsModal.dnsServer.address;
ObjectUtil.execute(dnsModal.confirm, newDnsServer);
},
@ -71,9 +85,10 @@
this.visible = true;
if (isEdit) {
if (typeof dnsServer == 'object') {
this.dnsServer = dnsServer;
this.dnsServer = { id: '', domains: [], expectIPs: [], ...dnsServer };
} else {
this.dnsServer = {
id: '',
address: dnsServer ?? "",
domains: [],
expectIPs: [],
@ -83,6 +98,7 @@
}
} else {
this.dnsServer = {
id: '',
address: "localhost",
domains: [],
expectIPs: [],

View file

@ -150,6 +150,7 @@
</a-col>
</a-row>
</a-list-item>
<setting-list-item type="text" title='{{ i18n "pages.xray.routingScript" }}' desc='{{ i18n "pages.xray.scriptDesc" }}' placeholder="route.lua" v-model="routingScript"></setting-list-item>
</a-collapse-panel>
<a-collapse-panel header='{{ i18n "pages.xray.logConfigs" }}'>
<a-row :xs="24" :sm="24" :lg="12">
@ -327,6 +328,7 @@
</a-col>
</a-row>
</a-list-item>
<setting-list-item type="text" title='{{ i18n "pages.xray.dns.script" }}' desc='{{ i18n "pages.xray.scriptDesc" }}' placeholder="dns.lua" v-model="dnsScript"></setting-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"
@ -1186,6 +1188,18 @@
this.templateSettings = newTemplateSettings;
}
},
routingScript: {
get: function () {
if (!this.templateSettings || !this.templateSettings.routing) return "";
return this.templateSettings.routing.script || "";
},
set: function (newValue) {
newTemplateSettings = this.templateSettings;
if (newValue.trim()) newTemplateSettings.routing.script = newValue.trim();
else delete newTemplateSettings.routing.script;
this.templateSettings = newTemplateSettings;
}
},
familyProtectSettings: {
get: function () {
if (!this.templateSettings || !this.templateSettings.dns || !this.templateSettings.dns.servers) return false;
@ -1233,6 +1247,17 @@
this.templateSettings = newTemplateSettings;
}
},
dnsScript: {
get: function () {
return this.enableDNS ? (this.templateSettings.dns.script || "") : "";
},
set: function (newValue) {
newTemplateSettings = this.templateSettings;
if (newValue.trim()) newTemplateSettings.dns.script = newValue.trim();
else delete newTemplateSettings.dns.script;
this.templateSettings = newTemplateSettings;
}
},
dnsStrategy: {
get: function () {
return this.enableDNS ? this.templateSettings.dns.queryStrategy : null;

View file

@ -681,6 +681,8 @@
"FreedomStrategyDesc" = "Set the output strategy for the network in the Freedom Protocol."
"RoutingStrategy" = "Overall Routing Strategy"
"RoutingStrategyDesc" = "Set the overall traffic routing strategy for resolving all requests."
"routingScript" = "Routing Script"
"scriptDesc" = "Path to a Lua script on the server, absolute or relative to the panel folder or bin/. Xray does not start while the file is missing."
"Torrent" = "Block BitTorrent Protocol"
"TorrentDesc" = "Blocks BitTorrent protocol."
"Family" = "Family Protection"
@ -792,6 +794,8 @@
"tagDesc" = "This tag will be available as an Inbound tag in routing rules."
"strategy" = "Query Strategy"
"strategyDesc" = "Overall strategy to resolve domain names."
"script" = "DNS Script"
"idDesc" = "Name a DNS script uses to find this server."
"add" = "Add Server"
"edit" = "Edit Server"
"domains" = "Domains"

View file

@ -681,6 +681,8 @@
"FreedomStrategyDesc" = "تعیین می‌کند Freedom استراتژی خروجی شبکه را برای پروتکل"
"RoutingStrategy" = "استراتژی کلی مسیریابی"
"RoutingStrategyDesc" = "استراتژی کلی مسیریابی برای حل تمام درخواست‌ها را تعیین می‌کند"
"routingScript" = "اسکریپت مسیریابی"
"scriptDesc" = "مسیر یک اسکریپت Lua روی سرور، کامل یا نسبت به پوشه‌ی پنل یا bin/. تا وقتی فایل وجود نداشته باشد Xray اجرا نمی‌شود."
"Torrent" = "مسدودسازی پروتکل بیت‌تورنت"
"TorrentDesc" = "پروتکل بیت تورنت را مسدود می‌کند"
"Family" = "محافظ خانواده"
@ -792,6 +794,8 @@
"tagDesc" = "این برچسب در قوانین مسیریابی به عنوان یک برچسب ورودی قابل استفاده خواهد بود"
"strategy" = "استراتژی پرس‌وجو"
"strategyDesc" = "استراتژی کلی برای حل نام‌دامنه"
"script" = "اسکریپت DNS"
"idDesc" = "نامی که اسکریپت DNS این سرور را با آن پیدا می‌کند."
"add" = "افزودن سرور"
"edit" = "ویرایش سرور"
"domains" = "دامنه‌ها"

View file

@ -681,6 +681,8 @@
"FreedomStrategyDesc" = "Установить стратегию вывода сети в протоколе Freedom"
"RoutingStrategy" = "Настроить доменную стратегию маршрутизации"
"RoutingStrategyDesc" = "Установить общую стратегию маршрутизации разрешения DNS"
"routingScript" = "Скрипт маршрутизации"
"scriptDesc" = "Путь к Lua-скрипту на сервере, абсолютный или относительно папки панели или bin/. Пока файла нет, Xray не запустится."
"Torrent" = "Запретить использование BitTorrent"
"TorrentDesc" = "Измените конфигурацию, чтобы пользователи не использовали BitTorrent."
"Family" = "Включить семейную конфигурацию"
@ -792,6 +794,8 @@
"tagDesc" = "Этот тег будет доступен как входящий тег в правилах маршрутизации."
"strategy" = "Стратегия запроса"
"strategyDesc" = "Общая стратегия разрешения доменных имен"
"script" = "Скрипт DNS"
"idDesc" = "Имя, по которому DNS-скрипт находит этот сервер."
"add" = "Добавить сервер"
"edit" = "Редактировать сервер"
"domains" = "Домены"

View file

@ -681,6 +681,8 @@
"FreedomStrategyDesc" = "Đặt chiến lược đầu ra của mạng trong Giao thức Tự do."
"RoutingStrategy" = "Định cấu hình chiến lược định tuyến tên miền"
"RoutingStrategyDesc" = "Đặt chiến lược định tuyến tổng thể để phân giải DNS."
"routingScript" = "Script định tuyến"
"scriptDesc" = "Đường dẫn tới script Lua trên máy chủ, tuyệt đối hoặc tương đối với thư mục panel hay bin/. Xray không khởi động khi thiếu tệp."
"Torrent" = "Cấm sử dụng BitTorrent"
"TorrentDesc" = "Thay đổi mẫu cấu hình để tránh việc người dùng sử dụng BitTorrent."
"Family" = "Kích hoạt cấu hình thân thiện với gia đình"
@ -792,6 +794,8 @@
"tagDesc" = "Thẻ này sẽ có sẵn dưới dạng thẻ Gửi đến trong quy tắc định tuyến."
"strategy" = "Chiến lược truy vấn"
"strategyDesc" = "Chiến lược tổng thể để phân giải tên miền"
"script" = "Script DNS"
"idDesc" = "Tên mà script DNS dùng để tìm máy chủ này."
"add" = "Thêm máy chủ"
"edit" = "Chỉnh sửa máy chủ"
"domains" = "Tên miền"

View file

@ -681,6 +681,8 @@
"FreedomStrategyDesc" = "在自由协议中设置网络输出策略"
"RoutingStrategy" = "配置路由域策略"
"RoutingStrategyDesc" = "设置DNS解析的整体路由策略"
"routingScript" = "路由脚本"
"scriptDesc" = "服务器上 Lua 脚本的路径,可为绝对路径,或相对于面板目录或 bin/。文件不存在时 Xray 无法启动。"
"Torrent" = "禁止使用 bitTorrent"
"TorrentDesc" = "更改配置模板避免用户使用 bitTorrent"
"Family" = "启用家庭友好配置"
@ -792,6 +794,8 @@
"tagDesc" = "此标记将在路由规则中用作入站标记。"
"strategy" = "查询策略"
"strategyDesc" = "解析域名的总体策略"
"script" = "DNS 脚本"
"idDesc" = "DNS 脚本用来查找此服务器的名称。"
"add" = "添加服务器"
"edit" = "编辑服务器"
"domains" = "域"