mirror of
				https://github.com/MHSanaei/3x-ui.git
				synced 2025-10-31 20:32:52 +00:00 
			
		
		
		
	clear log hourly if !j.hasLimitIp and "./access.log" exist
This commit is contained in:
		
							parent
							
								
									f5dacd28e1
								
							
						
					
					
						commit
						4daaf0a647
					
				
					 1 changed files with 18 additions and 1 deletions
				
			
		|  | @ -51,6 +51,23 @@ func (j *CheckClientIpJob) Run() { | |||
| 		j.checkFail2BanInstalled() | ||||
| 		j.processLogFile() | ||||
| 	} | ||||
| 
 | ||||
| 	if !j.hasLimitIp() && xray.GetAccessLogPath() == "./access.log" { | ||||
| 		go j.clearLogTime() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (j *CheckClientIpJob) clearLogTime() { | ||||
| 	for { | ||||
| 		time.Sleep(time.Hour) | ||||
| 		j.clearAccessLog() | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func (j *CheckClientIpJob) clearAccessLog() { | ||||
| 	accessLogPath := xray.GetAccessLogPath() | ||||
| 	err := os.Truncate(accessLogPath, 0) | ||||
| 	j.checkError(err) | ||||
| } | ||||
| 
 | ||||
| func (j *CheckClientIpJob) hasLimitIp() bool { | ||||
|  | @ -121,7 +138,7 @@ func (j *CheckClientIpJob) processLogFile() { | |||
| 		matches := ipRegx.FindStringSubmatch(line) | ||||
| 		if len(matches) > 1 { | ||||
| 			ip := matches[1] | ||||
| 			if ip == "127.0.0.1" || ip == "[::1]" { | ||||
| 			if ip == "127.0.0.1" { | ||||
| 				continue | ||||
| 			} | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in a new issue
	
	 MHSanaei
						MHSanaei