ソースを参照

minor changes

disAllowedIps doesn't show on debug if there is no ip
change copy to clipboard to export inbound
MHSanaei 1 年間 前
コミット
e7ce8c8ddb

+ 1 - 1
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

+ 2 - 2
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=

+ 1 - 1
web/html/xui/inbounds.html

@@ -230,7 +230,7 @@
                                         </template>
                                         <a-menu-item key="clipboard">
                                             <a-icon type="copy"></a-icon>
-                                            {{ i18n "pages.inbounds.copyToClipboard" }}
+                                            {{ i18n "pages.inbounds.exportInbound" }}
                                         </a-menu-item>
                                         <a-menu-item key="resetTraffic">
                                             <a-icon type="retweet"></a-icon> {{ i18n "pages.inbounds.resetTraffic" }}

+ 14 - 9
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

+ 1 - 1
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"
 

+ 1 - 1
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"
 

+ 1 - 1
web/translation/translate.fa_IR.toml

@@ -178,7 +178,7 @@
 "info" = "اطلاعات"
 "same" = "همسان"
 "inboundData" = "داده‌های ورودی"
-"copyToClipboard" = "کپی در حافظه"
+"exportInbound" = "استخراج ورودی"
 "import" = "افزودن"
 "importInbound" = "افزودن یک ورودی"
 

+ 1 - 1
web/translation/translate.ru_RU.toml

@@ -178,7 +178,7 @@
 "info" = "Информация"
 "same" = "Тот же"
 "inboundData" = "Входящие данные"
-"copyToClipboard" = "Копировать в буфер обмена"
+"exportInbound" = "Экспорт входящих"
 "import" = "Импортировать"
 "importInbound" = "Импортировать входящее сообщение"
 

+ 1 - 1
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"
 

+ 1 - 1
web/translation/translate.zh_Hans.toml

@@ -178,7 +178,7 @@
 "info" = "信息"
 "same" = "相同"
 "inboundData" = "入站数据"
-"copyToClipboard" = "复制到剪贴板"
+"exportInbound" = "出口 入境"
 "import"="导入"
 "importInbound" = "导入入站"