mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2025-09-09 19:56:19 +00:00
[fix] access log path
better to not hardcode the access log path, maybe some ppl dont want to use the default ./access.log
This commit is contained in:
parent
1d2e7f1b21
commit
76cce395f4
1 changed files with 18 additions and 11 deletions
|
@ -36,28 +36,20 @@ func (j *CheckClientIpJob) Run() {
|
|||
}
|
||||
|
||||
f2bInstalled := j.checkFail2BanInstalled()
|
||||
accessLogPath := xray.GetAccessLogPath()
|
||||
isAccessLogAvailable := j.checkAccessLogAvailable()
|
||||
clearAccessLog := false
|
||||
|
||||
if j.hasLimitIp() {
|
||||
if f2bInstalled && accessLogPath == "./access.log" {
|
||||
if f2bInstalled && isAccessLogAvailable {
|
||||
clearAccessLog = j.processLogFile()
|
||||
} else {
|
||||
if !f2bInstalled {
|
||||
logger.Warning("fail2ban is not installed. IP limiting may not work properly.")
|
||||
}
|
||||
switch accessLogPath {
|
||||
case "none":
|
||||
logger.Warning("Access log is set to 'none', check your Xray Configs")
|
||||
case "":
|
||||
logger.Warning("Access log doesn't exist in your Xray Configs")
|
||||
default:
|
||||
logger.Warning("Current access.log path is not compatible with IP Limit")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if clearAccessLog || accessLogPath == "./access.log" && time.Now().Unix() - j.lastClear > 3600 {
|
||||
if clearAccessLog || isAccessLogAvailable && time.Now().Unix()-j.lastClear > 3600 {
|
||||
j.clearAccessLog()
|
||||
}
|
||||
}
|
||||
|
@ -178,6 +170,21 @@ func (j *CheckClientIpJob) processLogFile() bool {
|
|||
return shouldCleanLog
|
||||
}
|
||||
|
||||
func (j *CheckClientIpJob) checkAccessLogAvailable() bool {
|
||||
accessLogPath := xray.GetAccessLogPath()
|
||||
isAvailable := true
|
||||
// access log is not available if it is set to 'none' or an empty string
|
||||
switch accessLogPath {
|
||||
case "none":
|
||||
logger.Warning("Access log is set to 'none', check your Xray Configs")
|
||||
isAvailable = false
|
||||
case "":
|
||||
logger.Warning("Access log doesn't exist in your Xray Configs")
|
||||
isAvailable = false
|
||||
}
|
||||
return isAvailable
|
||||
}
|
||||
|
||||
func (j *CheckClientIpJob) checkError(e error) {
|
||||
if e != nil {
|
||||
logger.Warning("client ip job err:", e)
|
||||
|
|
Loading…
Reference in a new issue