From c53cee31f5a64ed3292f977bf5a0749324eb78a2 Mon Sep 17 00:00:00 2001 From: Saeid <43953720+surbiks@users.noreply.github.com> Date: Tue, 6 Feb 2024 11:40:49 +0330 Subject: [PATCH] Manage balancers in settings UI (#1759) * add balancer config to ui * manage balancer in rules table * fix balancer translations * fix edit button text --- web/html/xui/xray.html | 166 ++++++++++++++++++++++++- web/html/xui/xray_balancer_modal.html | 111 +++++++++++++++++ web/html/xui/xray_rule_modal.html | 23 +++- web/translation/translate.en_US.toml | 11 ++ web/translation/translate.es_ES.toml | 11 ++ web/translation/translate.fa_IR.toml | 11 ++ web/translation/translate.ru_RU.toml | 11 ++ web/translation/translate.vi_VN.toml | 11 ++ web/translation/translate.zh_Hans.toml | 11 ++ 9 files changed, 363 insertions(+), 3 deletions(-) create mode 100644 web/html/xui/xray_balancer_modal.html diff --git a/web/html/xui/xray.html b/web/html/xui/xray.html index 267103cb..a144c766 100644 --- a/web/html/xui/xray.html +++ b/web/html/xui/xray.html @@ -327,6 +327,14 @@ [[ rule.outboundTag ]] + + + + Balancer Tag: [[ rule.balancerTag ]] + + [[ rule.balancerTag ]] + + + + {{ i18n "pages.xray.balancer.addBalancer"}} + + + [[ index+1 ]] + + e.preventDefault()" type="more" style="font-size: 16px; text-decoration: bold;"> + + + + {{ i18n "edit" }} + + + + {{ i18n "delete"}} + + + + + + + Random + Round Robin + + + [[ sel ]] + + + @@ -474,6 +517,7 @@ {{template "ruleModal"}} {{template "outModal"}} {{template "reverseModal"}} +{{template "balancerModal"}} {{template "warpModal"}} +{{end}} \ No newline at end of file diff --git a/web/html/xui/xray_rule_modal.html b/web/html/xui/xray_rule_modal.html index 9ed9e06a..07cc3217 100644 --- a/web/html/xui/xray_rule_modal.html +++ b/web/html/xui/xray_rule_modal.html @@ -107,6 +107,19 @@ [[ tag ]] + + + + + {{ i18n "pages.xray.balancer.balancerDesc" }} + + Balancer Tag + + + + [[ tag ]] + + @@ -133,11 +146,12 @@ protocol: [], attrs: [], outboundTag: "", + balancerTag: "", }, inboundTags: [], outboundTags: [], users: [], - balancerTag: [], + balancerTags: [], ok() { newRule = ruleModal.getResult(); ObjectUtil.execute(ruleModal.confirm, newRule); @@ -160,6 +174,7 @@ this.rule.protocol = rule.protocol; this.rule.attrs = rule.attrs ? Object.entries(rule.attrs) : []; this.rule.outboundTag = rule.outboundTag; + this.rule.balancerTag = rule.balancerTag ? rule.balancerTag : "" } else { this.rule = { domainMatcher: "", @@ -174,6 +189,7 @@ protocol: [], attrs: [], outboundTag: "", + balancerTag: "", } } this.isEdit = isEdit; @@ -186,6 +202,10 @@ } if(app.templateSettings.reverse.portals) this.outboundTags.push(...app.templateSettings.reverse.portals.map(b => b.tag)); } + + if (app.templateSettings.routing && app.templateSettings.routing.balancers) { + this.balancerTags = app.templateSettings.routing.balancers.filter((o) => !ObjectUtil.isEmpty(o.tag)).map(obj => obj.tag) + } }, close() { ruleModal.visible = false; @@ -211,6 +231,7 @@ rule.protocol = value.protocol; rule.attrs = Object.fromEntries(value.attrs); rule.outboundTag = value.outboundTag; + rule.balancerTag = value.balancerTag; for (const [key, value] of Object.entries(rule)) { if ( diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 78c545f6..68a61181 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -388,6 +388,7 @@ "Inbounds" = "Inbounds" "InboundsDesc" = "Accepting the specific clients." "Outbounds" = "Outbounds" +"Balancers" = "Balancers" "OutboundsDesc" = "Set the outgoing traffic pathway." "Routings" = "Routing Rules" "RoutingsDesc" = "The priority of each rule is important!" @@ -406,6 +407,7 @@ "dest" = "Destination" "inbound" = "Inbound" "outbound" = "Outbound" +"balancer" = "Balancer" "info" = "Info" "add" = "Add Rule" "edit" = "Edit Rule" @@ -426,6 +428,15 @@ "portal" = "Portal" "intercon" = "Interconnection" +[pages.xray.balancer] +"addBalancer" = "Add Balancer" +"editBalancer" = "Edit Balancer" +"balancerStrategy" = "Strategy" +"balancerSelectors" = "Selectors" +"tag" = "Tag" +"tagDesc" = "Unique Tag" +"balancerDesc" = "It is not possible to use balancerTag and outboundTag at the same time. If used at the same time, only outboundTag will work." + [pages.xray.wireguard] "secretKey" = "Secret Key" "publicKey" = "Public Key" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index b21fe252..ae4408fd 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -388,6 +388,7 @@ "Inbounds" = "Entrante" "InboundsDesc" = "Cambia la plantilla de configuración para aceptar clientes específicos." "Outbounds" = "Salidas" +"Balancers" = "Equilibradores" "OutboundsDesc" = "Cambia la plantilla de configuración para definir formas de salida para este servidor." "Routings" = "Reglas de enrutamiento" "RoutingsDesc" = "¡La prioridad de cada regla es importante!" @@ -406,6 +407,7 @@ "dest" = "Destino" "inbound" = "Entrante" "outbound" = "saliente" +"balancer" = "Balancín" "info" = "Información" "add" = "Agregar regla" "edit" = "Editar regla" @@ -426,6 +428,15 @@ "portal" = "portal" "intercon" = "Interconexión" +[pages.xray.balancer] +"addBalancer" = "Agregar equilibrador" +"editBalancer" = "Editar balanceador" +"balancerStrategy" = "Estrategia" +"balancerSelectors" = "Selectores" +"tag" = "Etiqueta" +"tagDesc" = "etiqueta única" +"balancerDesc" = "No es posible utilizar balancerTag y outboundTag al mismo tiempo. Si se utilizan al mismo tiempo, sólo funcionará outboundTag." + [pages.xray.wireguard] "secretKey" = "Llave secreta" "publicKey" = "Llave pública" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 7abaf973..114487a4 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -388,6 +388,7 @@ "Inbounds" = "ورودیها" "InboundsDesc" = "پذیرش کلاینت خاص" "Outbounds" = "خروجیها" +"Balancers" = "بالانسرها" "OutboundsDesc" = "مسیر ترافیک خروجی را تنظیم کنید" "Routings" = "قوانین مسیریابی" "RoutingsDesc" = "اولویت هر قانون مهم است" @@ -406,6 +407,7 @@ "dest" = "مقصد" "inbound" = "ورودی" "outbound" = "خروجی" +"balancer" = "بالانسر" "info" = "اطلاعات" "add" = "افزودن قانون" "edit" = "ویرایش قانون" @@ -426,6 +428,15 @@ "portal" = "پورتال" "intercon" = "اتصال میانی" +[pages.xray.balancer] +"addBalancer" = "افزودن بالانسر" +"editBalancer" = "ویرایش بالانسر" +"balancerStrategy" = "استراتژی" +"balancerSelectors" = "انتخابگرها" +"tag" = "برچسب" +"tagDesc" = "برچسب یگانه" +"balancerDesc" = "امکان استفاده همزمان balancerTag و outboundTag باهم وجود ندارد. درصورت استفاده همزمان فقط outboundTag عمل خواهد کرد." + [pages.xray.wireguard] "secretKey" = "کلید شخصی" "publicKey" = "کلید عمومی" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index cbd1d4f9..3c6799da 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -388,6 +388,7 @@ "Inbounds" = "Входящие" "InboundsDesc" = "Изменение шаблона конфигурации для подключения определенных пользователей" "Outbounds" = "Исходящие" +"Balancers" = "Балансиры" "OutboundsDesc" = "Изменение шаблона конфигурации, чтобы определить исходящие пути для этого сервера" "Routings" = "Правила маршрутизации" "RoutingsDesc" = "Важен приоритет каждого правила!" @@ -406,6 +407,7 @@ "dest" = "Пункт назначения" "inbound" = "Входящий" "outbound" = "Исходящий" +"balancer" = "балансир" "info" = "Информация" "add" = "Добавить правило" "edit" = "Редактировать правило" @@ -426,6 +428,15 @@ "portal" = "Портал" "intercon" = "Соединение" +[pages.xray.balancer] +"addBalancer" = "Добавить балансир" +"editBalancer" = "Редактировать балансир" +"balancerStrategy" = "Стратегия" +"balancerSelectors" = "Селекторы" +"tag" = "Тег" +"tagDesc" = "уникальный тег" +"balancerDesc" = "Невозможно одновременно использовать balancerTag и outboundTag. При одновременном использовании будет работать только outboundTag." + [pages.xray.wireguard] "secretKey" = "Секретный ключ" "publicKey" = "Открытый ключ" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index f94b56b0..286d9c83 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -388,6 +388,7 @@ "Inbounds" = "Đầu vào" "InboundsDesc" = "Thay đổi mẫu cấu hình để chấp nhận các máy khách cụ thể." "Outbounds" = "Đầu ra" +"Balancers" = "Cân bằng" "OutboundsDesc" = "Thay đổi mẫu cấu hình để xác định các cách ra đi cho máy chủ này." "Routings" = "Quy tắc định tuyến" "RoutingsDesc" = "Mức độ ưu tiên của mỗi quy tắc đều quan trọng!" @@ -406,6 +407,7 @@ "dest" = "Đích" "inbound" = "Vào" "outbound" = "Ra" +"balancer" = "Cân bằng" "info" = "Thông tin" "add" = "Thêm quy tắc" "edit" = "Chỉnh sửa quy tắc" @@ -426,6 +428,15 @@ "portal" = "Cổng thông tin" "intercon" = "Kết nối" +[pages.xray.balancer] +"addBalancer" = "Thêm cân bằng" +"editBalancer" = "Chỉnh sửa cân bằng" +"balancerStrategy" = "Chiến lược" +"balancerSelectors" = "Bộ chọn" +"tag" = "Thẻ" +"tagDesc" = "thẻ duy nhất" +"balancerDesc" = "Không thể sử dụng balancerTag và outboundTag cùng một lúc. Nếu sử dụng cùng lúc thì chỉ outboundTag mới hoạt động." + [pages.xray.wireguard] "secretKey" = "Khoá bí mật" "publicKey" = "Khóa công khai" diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml index d64e1331..bef4feeb 100644 --- a/web/translation/translate.zh_Hans.toml +++ b/web/translation/translate.zh_Hans.toml @@ -388,6 +388,7 @@ "Inbounds" = "入站" "InboundsDesc" = "更改配置模板接受特殊客户端" "Outbounds" = "出站" +"Balancers" = "平衡器" "OutboundsDesc" = "更改配置模板定义此服务器的传出方式" "Routings" = "路由规则" "RoutingsDesc" = "每条规则的优先级都很重要" @@ -406,6 +407,7 @@ "dest" = "目的地" "inbound" = "入站" "outbound" = "出站" +"balancer" = "平衡器" "info" = "信息" "add" = "添加规则" "edit" = "编辑规则" @@ -426,6 +428,15 @@ "portal" = "门户" "intercon" = "互连" +[pages.xray.balancer] +"addBalancer" = "添加平衡器" +"editBalancer" = "编辑平衡器" +"balancerStrategy" = "战略" +"balancerSelectors" = "选择器" +"tag" = "标签" +"tagDesc" = "唯一标记" +"balancerDesc" = "不能同时使用balancerTag和outboundTag。 如果同时使用,则只有outboundTag起作用。" + [pages.xray.wireguard] "secretKey" = "密钥" "publicKey" = "公钥"
Balancer Tag: [[ rule.balancerTag ]]