feat(xray): edit Lua DNS and routing scripts

xray-core 26.10.10 can hand DNS and routing to Lua: dns.script and
routing.script name a .lua file (absolute, or found next to the Xray
binary) that defines HandleDNSQuery / HandleRoute, and a DNS server's id
is how a DNS script picks it. The keys round-tripped through the JSON
template but had no field.

- DNS: a Lua Script field, and an ID field in the server modal;
- Basics: a Routing Script field beside the routing strategy;
- Routing: a warning above the rules while a script is set, since the
  core then routes only through the script and skips every rule, the
  panel's api rule included.

The descriptions say the script must still send the api inbound to the
api outbound, and that Xray will not start if the file is missing. An
empty field drops the key, because the core rejects an empty path.
This commit is contained in:
MHSanaei
2026-10-11 15:37:20 +02:00
parent 1c050f872a
commit b6c859f5b9
25 changed files with 338 additions and 30 deletions
@@ -151,6 +151,20 @@ put specific rules above general ones.
}
```
### Lua scripts
Xray 26.10.10 can hand routing and DNS to Lua. **Basics → Routing Script** takes the
path of a `.lua` file that defines `HandleRoute` (absolute, or relative to the Xray
`bin` folder); **DNS → Lua Script** takes one that defines `HandleDNSQuery`, and a
DNS server's **ID** is the name such a script picks it by.
<Callout type="warn">
A routing script replaces **every** routing rule, the panel's own `api` rule
included. Send the `api` inbound to the `api` outbound in your script, or traffic
statistics and live client changes stop. Xray does not start if the file is missing
or fails to load.
</Callout>
## Balancers
A **balancer** groups outbounds by a **selector** (tag prefixes, including the
@@ -152,6 +152,20 @@ Reset یا حذف، peer مربوط به WireGuard را در حساب PIA باط
}
```
### اسکریپت‌های Lua
Xray 26.10.10 می‌تواند مسیریابی و DNS را به Lua بسپارد. **پایه ← اسکریپت مسیریابی**
مسیر یک فایل `.lua` را می‌گیرد که `HandleRoute` را تعریف می‌کند (مطلق یا نسبت به
پوشه‌ی `bin` در Xray)؛ **DNS ← اسکریپت Lua** فایلی را می‌گیرد که `HandleDNSQuery` را
تعریف می‌کند، و **شناسه**‌ی هر سرور DNS نامی است که اسکریپت با آن سرور را انتخاب می‌کند.
<Callout type="warn">
اسکریپت مسیریابی جای **همه‌ی** قوانین مسیریابی را می‌گیرد، از جمله قانون `api` خود
پنل. در اسکریپت، اینباند `api` را به اوت‌باند `api` بفرستید، وگرنه آمار ترافیک و
اعمال زنده‌ی تغییرات کلاینت‌ها متوقف می‌شود. اگر فایل وجود نداشته باشد یا بارگذاری
نشود، Xray اجرا نمی‌شود.
</Callout>
## متعادل‌کننده‌ها
یک **متعادل‌کننده** خروجی‌ها را با یک **انتخاب‌گر** (پیشوندهای برچسب، از جمله مجموعه‌های
@@ -165,6 +165,20 @@ hostname получает уникальный тег `nord-<hostname>` и не
}
```
### Lua-скрипты
Xray 26.10.10 умеет передавать маршрутизацию и DNS в Lua. **Основное → Скрипт
маршрутизации** принимает путь к файлу `.lua` с функцией `HandleRoute` (абсолютный
или относительно папки `bin` Xray); **DNS → Lua-скрипт** — файл с функцией
`HandleDNSQuery`, а **ID** DNS-сервера — имя, по которому такой скрипт его выбирает.
<Callout type="warn">
Скрипт маршрутизации заменяет **все** правила маршрутизации, включая собственное
правило `api` панели. Направляйте в скрипте входящий `api` на исходящий `api`,
иначе остановятся статистика трафика и применение изменений клиентов на лету. Xray не
запустится, если файл отсутствует или не загружается.
</Callout>
## Балансировщики
**Балансировщик** группирует исходящие соединения по **селектору** (префиксы
@@ -140,6 +140,18 @@ Xray 配置中——而不会改动你已保存的模板。这是订阅一*池*
}
```
### Lua 脚本
Xray 26.10.10 可以把路由和 DNS 交给 Lua 处理。**基础配置 → 路由脚本** 填写定义了
`HandleRoute` 的 `.lua` 文件路径(绝对路径或相对于 Xray `bin` 目录);**DNS → Lua
脚本** 填写定义了 `HandleDNSQuery` 的文件,DNS 服务器的 **ID** 就是脚本选择它时使用的名称。
<Callout type="warn">
路由脚本会取代**全部**路由规则,包括面板自带的 `api` 规则。请在脚本中把 `api` 入站
发往 `api` 出站,否则流量统计和客户端变更的实时生效都会停止。文件不存在或加载失败时
Xray 无法启动。
</Callout>
## 均衡器
**均衡器**通过一个**选择器**(标签前缀,包括来自出站订阅的通配符池)将出站分组,