From 51a4d33a912b158809801de834817c74a091ad87 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 4 Apr 2026 05:26:18 +0000 Subject: [PATCH] feat: add per-inbound download/upload speed limit (KB/s) via Linux tc Agent-Logs-Url: https://github.com/xAlokyx/3x-ui/sessions/9e10f937-9919-4186-8ac8-caa00f2593b8 Co-authored-by: xAlokyx <234771438+xAlokyx@users.noreply.github.com> --- database/model/model.go | 4 + web/assets/js/model/dbinbound.js | 2 + web/html/form/inbound.html | 28 ++++ web/html/inbounds.html | 4 + web/service/inbound.go | 23 +++- web/service/speedlimit.go | 192 +++++++++++++++++++++++++++ web/translation/translate.ar_EG.toml | 3 + web/translation/translate.en_US.toml | 3 + web/translation/translate.es_ES.toml | 3 + web/translation/translate.fa_IR.toml | 3 + web/translation/translate.id_ID.toml | 3 + web/translation/translate.ja_JP.toml | 3 + web/translation/translate.pt_BR.toml | 3 + web/translation/translate.ru_RU.toml | 3 + web/translation/translate.tr_TR.toml | 3 + web/translation/translate.uk_UA.toml | 3 + web/translation/translate.vi_VN.toml | 3 + web/translation/translate.zh_CN.toml | 3 + web/translation/translate.zh_TW.toml | 3 + web/web.go | 19 ++- 20 files changed, 306 insertions(+), 5 deletions(-) create mode 100644 web/service/speedlimit.go diff --git a/database/model/model.go b/database/model/model.go index 6225df52..82b9f331 100644 --- a/database/model/model.go +++ b/database/model/model.go @@ -45,6 +45,10 @@ type Inbound struct { LastTrafficResetTime int64 `json:"lastTrafficResetTime" form:"lastTrafficResetTime" gorm:"default:0"` // Last traffic reset timestamp ClientStats []xray.ClientTraffic `gorm:"foreignKey:InboundId;references:Id" json:"clientStats" form:"clientStats"` // Client traffic statistics + // Speed limit fields (KB/s, 0 = unlimited) + SpeedLimitDown int64 `json:"speedLimitDown" form:"speedLimitDown" gorm:"default:0"` // Download speed limit in KB/s + SpeedLimitUp int64 `json:"speedLimitUp" form:"speedLimitUp" gorm:"default:0"` // Upload speed limit in KB/s + // Xray configuration fields Listen string `json:"listen" form:"listen"` Port int `json:"port" form:"port"` diff --git a/web/assets/js/model/dbinbound.js b/web/assets/js/model/dbinbound.js index befc618e..97583a7b 100644 --- a/web/assets/js/model/dbinbound.js +++ b/web/assets/js/model/dbinbound.js @@ -12,6 +12,8 @@ class DBInbound { this.expiryTime = 0; this.trafficReset = "never"; this.lastTrafficResetTime = 0; + this.speedLimitDown = 0; + this.speedLimitUp = 0; this.listen = ""; this.port = 0; diff --git a/web/html/form/inbound.html b/web/html/form/inbound.html index 8b59dc28..f27d7e59 100644 --- a/web/html/form/inbound.html +++ b/web/html/form/inbound.html @@ -49,6 +49,34 @@ :min="0"> + + + + + + + + + +