From e7ce8c8ddb8472695b296eac305c5ac9b8c1d3d8 Mon Sep 17 00:00:00 2001 From: MHSanaei Date: Sun, 21 Jan 2024 14:39:15 +0330 Subject: [PATCH] minor changes disAllowedIps doesn't show on debug if there is no ip change copy to clipboard to export inbound --- go.mod | 2 +- go.sum | 4 ++-- web/html/xui/inbounds.html | 2 +- web/job/check_client_ip_job.go | 23 ++++++++++++++--------- web/translation/translate.en_US.toml | 2 +- web/translation/translate.es_ES.toml | 2 +- web/translation/translate.fa_IR.toml | 2 +- web/translation/translate.ru_RU.toml | 2 +- web/translation/translate.vi_VN.toml | 2 +- web/translation/translate.zh_Hans.toml | 2 +- 10 files changed, 24 insertions(+), 19 deletions(-) diff --git a/go.mod b/go.mod index 6a116ba3..4e84c3e2 100644 --- a/go.mod +++ b/go.mod @@ -36,7 +36,7 @@ require ( github.com/go-ole/go-ole v1.3.0 // indirect github.com/go-playground/locales v0.14.1 // indirect github.com/go-playground/universal-translator v0.18.1 // indirect - github.com/go-playground/validator/v10 v10.16.0 // indirect + github.com/go-playground/validator/v10 v10.17.0 // indirect github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 // indirect github.com/golang/protobuf v1.5.3 // indirect github.com/google/btree v1.1.2 // indirect diff --git a/go.sum b/go.sum index 0b593906..f5d3b46b 100644 --- a/go.sum +++ b/go.sum @@ -76,8 +76,8 @@ github.com/go-playground/universal-translator v0.18.0/go.mod h1:UvRDBj+xPUEGrFYl github.com/go-playground/universal-translator v0.18.1 h1:Bcnm0ZwsGyWbCzImXv+pAJnYK9S473LQFuzCbDbfSFY= github.com/go-playground/universal-translator v0.18.1/go.mod h1:xekY+UJKNuX9WP91TpwSH2VMlDf28Uj24BCp08ZFTUY= github.com/go-playground/validator/v10 v10.10.0/go.mod h1:74x4gJWsvQexRdW8Pn3dXSGrTK4nAUsbPlLADvpJkos= -github.com/go-playground/validator/v10 v10.16.0 h1:x+plE831WK4vaKHO/jpgUGsvLKIqRRkz6M78GuJAfGE= -github.com/go-playground/validator/v10 v10.16.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= +github.com/go-playground/validator/v10 v10.17.0 h1:SmVVlfAOtlZncTxRuinDPomC2DkXJ4E5T9gDA0AIH74= +github.com/go-playground/validator/v10 v10.17.0/go.mod h1:9iXMNT7sEkjXb0I+enO7QXmzG6QCsPWY4zveKFVRSyU= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572 h1:tfuBGBXKqDEevZMzYi5KSi8KkcZtzBcTgAUUtapy0OI= github.com/go-task/slim-sprig v0.0.0-20230315185526-52ccab3ef572/go.mod h1:9Pwr4B2jHnOSGXyyzV8ROjYa2ojvAY6HCGYYfMoC3Ls= github.com/goccy/go-json v0.9.7/go.mod h1:6MelG93GURQebXPDq3khkgXZkazVtN9CRI+MGFi0w8I= diff --git a/web/html/xui/inbounds.html b/web/html/xui/inbounds.html index 79326ca2..c986e3fd 100644 --- a/web/html/xui/inbounds.html +++ b/web/html/xui/inbounds.html @@ -230,7 +230,7 @@ - {{ i18n "pages.inbounds.copyToClipboard" }} + {{ i18n "pages.inbounds.exportInbound" }} {{ i18n "pages.inbounds.resetTraffic" }} diff --git a/web/job/check_client_ip_job.go b/web/job/check_client_ip_job.go index 65257170..b393e68d 100644 --- a/web/job/check_client_ip_job.go +++ b/web/job/check_client_ip_job.go @@ -16,17 +16,18 @@ import ( "x-ui/xray" ) -type CheckClientIpJob struct{} +type CheckClientIpJob struct { + disAllowedIps []string +} var job *CheckClientIpJob -var disAllowedIps []string var ipFiles = []string{ xray.GetIPLimitLogPath(), -xray.GetIPLimitPrevLogPath(), + xray.GetIPLimitPrevLogPath(), xray.GetIPLimitBannedLogPath(), -xray.GetIPLimitBannedPrevLogPath(), + xray.GetIPLimitBannedPrevLogPath(), xray.GetAccessPersistentLogPath(), -xray.GetAccessPersistentPrevLogPath(), + xray.GetAccessPersistentPrevLogPath(), } func NewCheckClientIpJob() *CheckClientIpJob { @@ -130,7 +131,6 @@ func (j *CheckClientIpJob) processLogFile() { } } - disAllowedIps = []string{} shouldCleanLog := false for clientEmail, ips := range InboundClientIps { @@ -237,6 +237,7 @@ func (j *CheckClientIpJob) updateInboundClientIps(inboundClientIps *model.Inboun json.Unmarshal([]byte(inbound.Settings), &settings) clients := settings["clients"] shouldCleanLog := false + j.disAllowedIps = []string{} // create iplimit log file channel logIpFile, err := os.OpenFile(xray.GetIPLimitLogPath(), os.O_CREATE|os.O_APPEND|os.O_RDWR, 0644) @@ -255,7 +256,7 @@ func (j *CheckClientIpJob) updateInboundClientIps(inboundClientIps *model.Inboun shouldCleanLog = true if limitIp < len(ips) && inbound.Enable { - disAllowedIps = append(disAllowedIps, ips[limitIp:]...) + j.disAllowedIps = append(j.disAllowedIps, ips[limitIp:]...) for i := limitIp; i < len(ips); i++ { log.Printf("[LIMIT_IP] Email = %s || SRC = %s", clientEmail, ips[i]) } @@ -263,8 +264,12 @@ func (j *CheckClientIpJob) updateInboundClientIps(inboundClientIps *model.Inboun } } } - logger.Debug("disAllowedIps ", disAllowedIps) - sort.Strings(disAllowedIps) + + sort.Strings(j.disAllowedIps) + + if len(j.disAllowedIps) > 0 { + logger.Debug("disAllowedIps ", j.disAllowedIps) + } db := database.GetDB() err = db.Save(inboundClientIps).Error diff --git a/web/translation/translate.en_US.toml b/web/translation/translate.en_US.toml index 2f1c0544..006378ab 100644 --- a/web/translation/translate.en_US.toml +++ b/web/translation/translate.en_US.toml @@ -178,7 +178,7 @@ "info" = "Info" "same" = "Same" "inboundData" = "Inbound's Data" -"copyToClipboard" = "Copy to Clipboard" +"exportInbound" = "Export Inbound" "import" = "Import" "importInbound" = "Import an Inbound" diff --git a/web/translation/translate.es_ES.toml b/web/translation/translate.es_ES.toml index 42a3a2b2..bbf50b6c 100644 --- a/web/translation/translate.es_ES.toml +++ b/web/translation/translate.es_ES.toml @@ -178,7 +178,7 @@ "info" = "Info" "same" = "misma" "inboundData" = "Datos de entrada" -"copyToClipboard" = "Copiar al portapapeles" +"exportInbound" = "Exportación entrante" "import" = "Importar" "importInbound" = "Importar un entrante" diff --git a/web/translation/translate.fa_IR.toml b/web/translation/translate.fa_IR.toml index 3edcb4cb..1de8538c 100644 --- a/web/translation/translate.fa_IR.toml +++ b/web/translation/translate.fa_IR.toml @@ -178,7 +178,7 @@ "info" = "اطلاعات" "same" = "همسان" "inboundData" = "داده‌های ورودی" -"copyToClipboard" = "کپی در حافظه" +"exportInbound" = "استخراج ورودی" "import" = "افزودن" "importInbound" = "افزودن یک ورودی" diff --git a/web/translation/translate.ru_RU.toml b/web/translation/translate.ru_RU.toml index d8211d8d..2f33311e 100644 --- a/web/translation/translate.ru_RU.toml +++ b/web/translation/translate.ru_RU.toml @@ -178,7 +178,7 @@ "info" = "Информация" "same" = "Тот же" "inboundData" = "Входящие данные" -"copyToClipboard" = "Копировать в буфер обмена" +"exportInbound" = "Экспорт входящих" "import" = "Импортировать" "importInbound" = "Импортировать входящее сообщение" diff --git a/web/translation/translate.vi_VN.toml b/web/translation/translate.vi_VN.toml index 7491a70c..1a2cfaa0 100644 --- a/web/translation/translate.vi_VN.toml +++ b/web/translation/translate.vi_VN.toml @@ -178,7 +178,7 @@ "info" = "Thông tin" "same" = "Giống nhau" "inboundData" = "Dữ liệu gửi đến" -"copyToClipboard" = "Sao chép vào bảng nhớ tạm" +"exportInbound" = "Xuất nhập khẩu" "import" = "Nhập" "importInbound" = "Nhập inbound" diff --git a/web/translation/translate.zh_Hans.toml b/web/translation/translate.zh_Hans.toml index 5a46ec73..966ef3f7 100644 --- a/web/translation/translate.zh_Hans.toml +++ b/web/translation/translate.zh_Hans.toml @@ -178,7 +178,7 @@ "info" = "信息" "same" = "相同" "inboundData" = "入站数据" -"copyToClipboard" = "复制到剪贴板" +"exportInbound" = "出口 入境" "import"="导入" "importInbound" = "导入入站"