mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-11-16 18:15:01 +03:00
feat(sub): leastLoad member weights for subscription balancers (#6304)
* feat(model): add MemberWeights to SubBalancer Per-inbound leastLoad weights, stored with the same gorm json serializer as InboundIds so AutoMigrate adds the text column on every dialect (postgresModelSettled sees the missing column and re-runs). Absent entries mean weight 1.0; only meaningful for strategy leastLoad. * feat(sub): accept memberWeights on the sub-balancer API Parsed as one JSON form field (gin cannot bind bracket-keyed maps from urlencoded bodies). validate() rejects weights under any strategy but leastLoad — xray would silently ignore costs there, so storing them would pretend a knob exists. Non-positive weights error instead of defaulting: a zero usually means a typo'd "never pick this node". Entries for inbounds no longer selected are dropped on save. * feat(sub): emit leastLoad strategy costs from member weights costs[] is built after the tagging loop reuses the exact retagged tags (bal-N-protocol[-k]) and each member's owning inbound id. Members without a configured weight default to 1.0, but costs are omitted entirely unless at least one explicit weight survives — an all-1.0 array would bloat every subscription response for no effect. * feat(sub-balancers): leastLoad member weight inputs Weight fields render only under leastLoad and hide on strategy change without dropping their values, so an accidental toggle away and back loses nothing until save; non-leastLoad submits strip them entirely because xray would ignore costs. Weights travel as one JSON form field (gin cannot bind bracket-keyed maps) and every locale gets the three new keys in the same commit per the dead-keys rule. * docs(api): document memberWeights on sub-balancers leastLoad-only JSON form field; update notes that omitting it clears stored weights. Regenerated openapi artifacts via make gen + the docs copy/gen:api step nothing checks automatically. * fix(api-docs): use the allowed object ParamType for memberWeights * fix(sub-balancers): cap the member-weight list height Many selected inbounds pushed the modal body past the viewport. The weight rows now scroll inside a 220px viewport, mirroring the inbound picker's listHeight so both lists read the same. * fix(sub): anchor leastLoad cost matches to exact member tags Verified against xray-core: without regexp, WeightManager matches costs by substring (strings.Index), so the bare tag "bal-1-vless" also hits the deduplicated "bal-1-vless-2" and both members get the first entry's weight. Anchored ^tag$ regexps make every cost entry match only its own member. Also confirmed value<=0 makes xray derive a weight from the first digit of the matched tag — validating weights > 0 server-side was the right call. * fix(sub-balancers): keep member weights across the enabled toggle The table's toggleEnabled re-posted a full-row payload without memberWeights, and the update path treats an absent key as "erase" — flipping the switch silently dropped every configured weight. Round-trip the stored weights through the toggle payload, and prove persistence with a re-Get in the weight-validation test (the returned struct alone would stay green even if Save skipped the column). * fix(sub-balancers): address review on member weights - omitempty on MemberWeights: the panel sends null for every pre-existing and non-leastLoad balancer, which failed the hand-written zod response schema on every fetch (zod .optional() accepts undefined only; switched to .nullish() per repo convention) and drifted the generated contract. Regenerated openapi artifacts + docs copy + MDX. - Bound weights to the positive float32 range: xray decodes costs as float32, so an over-range value makes clients reject the whole subscription document and an underflow decays to the tag-digit fallback weight. Tests for both directions. - Trim six comment blocks to the 2-line cap from CLAUDE.md. --------- Co-authored-by: DIMFLIX <dimflix@users.noreply.github.com>
This commit is contained in:
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "الموضع في قائمة الاشتراك، متداخل مع ترتيب الإينبوندات؛ عند تساوي الرقم يأتي الموزّع بعد الإينباند.",
|
||||
"inbounds": "الإينبوندات",
|
||||
"inboundsCount": "{count} الإينبوندات",
|
||||
"weights": "أوزان الأعضاء",
|
||||
"weightsHelp": "لـ LeastLoad فقط: الوزن الأقل يُختار أكثر؛ العضو بدون قيمة وزنه 1.",
|
||||
"enabled": "مُفعّل",
|
||||
"empty": "لا يوجد موزّعات بعد",
|
||||
"deleteConfirm": "حذف هذا الموزّع؟",
|
||||
"errRemarkRequired": "الملاحظة مطلوبة",
|
||||
"errInboundsRequired": "اختر إينبوندًا واحدًا على الأقل",
|
||||
"errSortOrder": "الترتيب يجب أن يكون عددًا صحيحًا ≥ 1",
|
||||
"errWeightPositive": "يجب أن تكون الأوزان أكبر من 0",
|
||||
"toasts": {
|
||||
"list": "تعذّر عرض موزّعات الاشتراك",
|
||||
"create": "تعذّر إنشاء موزّع اشتراك",
|
||||
|
||||
@@ -1538,12 +1538,15 @@
|
||||
"sortOrderHelp": "Position in the subscription list, interleaved with the inbounds' own order; on equal numbers the balancer comes after the inbound.",
|
||||
"inbounds": "Inbounds",
|
||||
"inboundsCount": "{count} Inbounds",
|
||||
"weights": "Member weights",
|
||||
"weightsHelp": "Only for LeastLoad: a lower weight is picked more often; members without a value weigh 1.",
|
||||
"enabled": "Enabled",
|
||||
"empty": "No balancers yet",
|
||||
"deleteConfirm": "Delete this balancer?",
|
||||
"errRemarkRequired": "Remark is required",
|
||||
"errInboundsRequired": "Select at least one inbound",
|
||||
"errSortOrder": "Order must be a whole number ≥ 1",
|
||||
"errWeightPositive": "Weights must be greater than 0",
|
||||
"toasts": {
|
||||
"list": "Failed to list subscription balancers",
|
||||
"create": "Failed to create subscription balancer",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "Posición en la lista de la suscripción, intercalada con el orden de los inbounds; con el mismo número, el balanceador va después del inbound.",
|
||||
"inbounds": "Inbounds",
|
||||
"inboundsCount": "{count} Inbounds",
|
||||
"weights": "Pesos de miembros",
|
||||
"weightsHelp": "Solo para LeastLoad: un peso más bajo se elige con más frecuencia; los miembros sin valor pesan 1.",
|
||||
"enabled": "Activado",
|
||||
"empty": "Aún no hay balanceadores",
|
||||
"deleteConfirm": "¿Eliminar este balanceador?",
|
||||
"errRemarkRequired": "El comentario es obligatorio",
|
||||
"errInboundsRequired": "Selecciona al menos un inbound",
|
||||
"errSortOrder": "El orden debe ser un número entero ≥ 1",
|
||||
"errWeightPositive": "Los pesos deben ser mayores que 0",
|
||||
"toasts": {
|
||||
"list": "No se pudieron listar los balanceadores de suscripción",
|
||||
"create": "No se pudo crear el balanceador de suscripción",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "جایگاه در فهرست اشتراک، درهمتنیده با ترتیب اینباندها؛ با شمارهٔ برابر، موزانکننده بعد از اینباند میآید.",
|
||||
"inbounds": "اینباندها",
|
||||
"inboundsCount": "{count} اینباندها",
|
||||
"weights": "وزن اعضا",
|
||||
"weightsHelp": "فقط برای LeastLoad: وزن کمتر بیشتر انتخاب میشود؛ عضوی که مقداری نداشته باشد وزن ۱ دارد.",
|
||||
"enabled": "فعال",
|
||||
"empty": "هنوز موزانکنندهای وجود ندارد",
|
||||
"deleteConfirm": "این موزانکننده حذف شود؟",
|
||||
"errRemarkRequired": "توضیح الزامی است",
|
||||
"errInboundsRequired": "حداقل یک اینباند انتخاب کنید",
|
||||
"errSortOrder": "ترتیب باید عدد صحیح ≥ ۱ باشد",
|
||||
"errWeightPositive": "وزنها باید بزرگتر از ۰ باشند",
|
||||
"toasts": {
|
||||
"list": "فهرستسازی موزانکنندههای اشتراک ناموفق بود",
|
||||
"create": "ایجاد موزانکننده اشتراک ناموفق بود",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "Posisi dalam daftar langganan, berselang-seling dengan urutan inbound; jika sama, penyeimbang berada setelah inbound.",
|
||||
"inbounds": "Inbound",
|
||||
"inboundsCount": "{count} Inbound",
|
||||
"weights": "Bobot anggota",
|
||||
"weightsHelp": "Hanya untuk LeastLoad: bobot lebih rendah lebih sering dipilih; anggota tanpa nilai berbobot 1.",
|
||||
"enabled": "Aktif",
|
||||
"empty": "Belum ada penyeimbang",
|
||||
"deleteConfirm": "Hapus penyeimbang ini?",
|
||||
"errRemarkRequired": "Keterangan wajib diisi",
|
||||
"errInboundsRequired": "Pilih minimal satu inbound",
|
||||
"errSortOrder": "Urutan harus bilangan bulat ≥ 1",
|
||||
"errWeightPositive": "Bobot harus lebih besar dari 0",
|
||||
"toasts": {
|
||||
"list": "Gagal menampilkan daftar penyeimbang langganan",
|
||||
"create": "Gagal membuat penyeimbang langganan",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "サブスクリプション一覧内の位置。インバウンドの順序と交互に並び、同番号の場合はインバウンドの後ろになります。",
|
||||
"inbounds": "インバウンド",
|
||||
"inboundsCount": "{count} インバウンド",
|
||||
"weights": "メンバーの重み",
|
||||
"weightsHelp": "LeastLoad のみ:値が小さいほど選ばれやすくなります。未指定のメンバーは重み 1 です。",
|
||||
"enabled": "有効",
|
||||
"empty": "バランサーはまだありません",
|
||||
"deleteConfirm": "このバランサーを削除しますか?",
|
||||
"errRemarkRequired": "備考を入力してください",
|
||||
"errInboundsRequired": "インバウンドを1つ以上選択してください",
|
||||
"errSortOrder": "順序は1以上の整数にしてください",
|
||||
"errWeightPositive": "重みは 0 より大きい必要があります",
|
||||
"toasts": {
|
||||
"list": "サブスクリプションバランサーの一覧取得に失敗しました",
|
||||
"create": "サブスクリプションバランサーの作成に失敗しました",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "Posição na lista da assinatura, intercalada com a ordem dos inbounds; em caso de empate, o balanceador vem depois do inbound.",
|
||||
"inbounds": "Inbounds",
|
||||
"inboundsCount": "{count} Inbounds",
|
||||
"weights": "Pesos dos membros",
|
||||
"weightsHelp": "Apenas para LeastLoad: peso menor é escolhido com mais frequência; membros sem valor têm peso 1.",
|
||||
"enabled": "Ativado",
|
||||
"empty": "Ainda não há balanceadores",
|
||||
"deleteConfirm": "Excluir este balanceador?",
|
||||
"errRemarkRequired": "A descrição é obrigatória",
|
||||
"errInboundsRequired": "Selecione ao menos um inbound",
|
||||
"errSortOrder": "A ordem deve ser um inteiro ≥ 1",
|
||||
"errWeightPositive": "Os pesos devem ser maiores que 0",
|
||||
"toasts": {
|
||||
"list": "Falha ao listar os balanceadores de assinatura",
|
||||
"create": "Falha ao criar o balanceador de assinatura",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "Позиция в списке подписки, чередуется с порядком инбаундов; при равных номерах балансировщик идёт после инбаунда.",
|
||||
"inbounds": "Инбаунды",
|
||||
"inboundsCount": "{count} Инбаунды",
|
||||
"weights": "Веса участников",
|
||||
"weightsHelp": "Только для LeastLoad: чем меньше вес, тем чаще выбирается участник; без значения вес равен 1.",
|
||||
"enabled": "Включён",
|
||||
"empty": "Балансировщиков пока нет",
|
||||
"deleteConfirm": "Удалить этот балансировщик?",
|
||||
"errRemarkRequired": "Укажите примечание",
|
||||
"errInboundsRequired": "Выберите хотя бы один инбаунд",
|
||||
"errSortOrder": "Порядок — целое число ≥ 1",
|
||||
"errWeightPositive": "Веса должны быть больше 0",
|
||||
"toasts": {
|
||||
"list": "Не удалось получить список балансировщиков подписки",
|
||||
"create": "Не удалось создать балансировщик подписки",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "Abonelik listesindeki konumu, inbound sırası ile iç içe yerleşir; eşit numarada dengeleyici inbound'dan sonra gelir.",
|
||||
"inbounds": "Inbound'lar",
|
||||
"inboundsCount": "{count} Inbound'lar",
|
||||
"weights": "Üye ağırlıkları",
|
||||
"weightsHelp": "Yalnızca LeastLoad için: daha düşük ağırlık daha sık seçilir; değeri olmayan üyelerin ağırlığı 1’dir.",
|
||||
"enabled": "Etkin",
|
||||
"empty": "Henüz dengeleyici yok",
|
||||
"deleteConfirm": "Bu dengeleyici silinsin mi?",
|
||||
"errRemarkRequired": "Açıklama zorunludur",
|
||||
"errInboundsRequired": "En az bir inbound seçin",
|
||||
"errSortOrder": "Sıra 1 veya daha büyük bir tam sayı olmalı",
|
||||
"errWeightPositive": "Ağırlıklar 0’dan büyük olmalıdır",
|
||||
"toasts": {
|
||||
"list": "Abonelik dengeleyicileri listelenemedi",
|
||||
"create": "Abonelik dengeleyicisi oluşturulamadı",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "Позиція у списку підписки, чергується з порядком інбаундів; за однакового номера йде після інбаунда.",
|
||||
"inbounds": "Інбаунди",
|
||||
"inboundsCount": "{count} Інбаунди",
|
||||
"weights": "Ваги учасників",
|
||||
"weightsHelp": "Лише для LeastLoad: чим менша вага, тим частіше обирається учасник; без значення вага дорівнює 1.",
|
||||
"enabled": "Увімкнено",
|
||||
"empty": "Балансувальників ще немає",
|
||||
"deleteConfirm": "Видалити цей балансувальник?",
|
||||
"errRemarkRequired": "Вкажіть примітку",
|
||||
"errInboundsRequired": "Виберіть хоча б один інбаунд",
|
||||
"errSortOrder": "Порядок — ціле число ≥ 1",
|
||||
"errWeightPositive": "Ваги повинні бути більшими за 0",
|
||||
"toasts": {
|
||||
"list": "Не вдалося отримати список балансувальників підписки",
|
||||
"create": "Не вдалося створити балансувальник підписки",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "Vị trí trong danh sách đăng ký, xen kẽ với thứ tự inbound; khi cùng số, bộ cân bằng đứng sau inbound.",
|
||||
"inbounds": "Inbound",
|
||||
"inboundsCount": "{count} Inbound",
|
||||
"weights": "Trọng số thành viên",
|
||||
"weightsHelp": "Chỉ dành cho LeastLoad: trọng số nhỏ hơn được chọn thường xuyên hơn; thành viên không có giá trị mang trọng số 1.",
|
||||
"enabled": "Đã bật",
|
||||
"empty": "Chưa có bộ cân bằng nào",
|
||||
"deleteConfirm": "Xóa bộ cân bằng này?",
|
||||
"errRemarkRequired": "Cần nhập ghi chú",
|
||||
"errInboundsRequired": "Chọn ít nhất một inbound",
|
||||
"errSortOrder": "Thứ tự phải là số nguyên ≥ 1",
|
||||
"errWeightPositive": "Trọng số phải lớn hơn 0",
|
||||
"toasts": {
|
||||
"list": "Không thể liệt kê các bộ cân bằng đăng ký",
|
||||
"create": "Không thể tạo bộ cân bằng đăng ký",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "在订阅列表中的位置,与入站顺序交错排列;序号相同时排在入站之后。",
|
||||
"inbounds": "入站",
|
||||
"inboundsCount": "{count} 入站",
|
||||
"weights": "成员权重",
|
||||
"weightsHelp": "仅适用于 LeastLoad:权重越小越常被选中;未设置的成员权重为 1。",
|
||||
"enabled": "启用",
|
||||
"empty": "暂无均衡器",
|
||||
"deleteConfirm": "确定删除此均衡器?",
|
||||
"errRemarkRequired": "请填写备注",
|
||||
"errInboundsRequired": "请至少选择一个入站",
|
||||
"errSortOrder": "顺序必须为不小于 1 的整数",
|
||||
"errWeightPositive": "权重必须大于 0",
|
||||
"toasts": {
|
||||
"list": "列出订阅均衡器失败",
|
||||
"create": "创建订阅均衡器失败",
|
||||
|
||||
@@ -1420,12 +1420,15 @@
|
||||
"sortOrderHelp": "在訂閱列表中的位置,與入站順序交錯排列;序號相同時排在入站之後。",
|
||||
"inbounds": "入站",
|
||||
"inboundsCount": "{count} 入站",
|
||||
"weights": "成員權重",
|
||||
"weightsHelp": "僅適用於 LeastLoad:權重越小越常被選中;未設定的成員權重為 1。",
|
||||
"enabled": "啟用",
|
||||
"empty": "尚無平衡器",
|
||||
"deleteConfirm": "確定刪除此平衡器?",
|
||||
"errRemarkRequired": "請填寫備註",
|
||||
"errInboundsRequired": "請至少選擇一個入站",
|
||||
"errSortOrder": "順序必須為不小於 1 的整數",
|
||||
"errWeightPositive": "權重必須大於 0",
|
||||
"toasts": {
|
||||
"list": "列出訂閱平衡器失敗",
|
||||
"create": "建立訂閱平衡器失敗",
|
||||
|
||||
Reference in New Issue
Block a user