fix w trackerze
This commit is contained in:
		
							
								
								
									
										13
									
								
								logmon.py
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								logmon.py
									
									
									
									
									
								
							| @@ -150,6 +150,10 @@ class LogMonDaemon: | ||||
|             ip: Adres IP atakującego | ||||
|             score: Punkty za dane niepowodzenie (domyślnie 1) | ||||
|         """ | ||||
|         if ip in self.banned_ips: | ||||
|             self.logger.debug(f"IP {ip} already banned, ignoring") | ||||
|             return | ||||
|          | ||||
|         now = datetime.now() | ||||
|          | ||||
|         # Dodaj wpis do trackera | ||||
| @@ -157,7 +161,7 @@ class LogMonDaemon: | ||||
|          | ||||
|         # Usuń stare wpisy spoza okna czasowego | ||||
|         time_window = self.config.getint('module_postfix', 'time_window',  | ||||
|                                          fallback=60) | ||||
|                                         fallback=60) | ||||
|         cutoff = now - timedelta(seconds=time_window) | ||||
|          | ||||
|         while self.ip_tracker[ip] and self.ip_tracker[ip][0][0] < cutoff: | ||||
| @@ -168,17 +172,16 @@ class LogMonDaemon: | ||||
|         failures_count = len(self.ip_tracker[ip]) | ||||
|          | ||||
|         max_failures = self.config.getint('module_postfix', 'max_failures',  | ||||
|                                          fallback=5) | ||||
|                                         fallback=5) | ||||
|          | ||||
|         self.logger.debug( | ||||
|             f"IP {ip}: {failures_count} failures, score {total_score}/{max_failures}" | ||||
|         ) | ||||
|          | ||||
|         # Sprawdź czy przekroczono limit | ||||
|         if total_score >= max_failures and ip not in self.banned_ips: | ||||
|         if total_score >= max_failures: | ||||
|             self.ban_ip(ip) | ||||
|         elif total_score >= max_failures and ip in self.banned_ips: | ||||
|             self.logger.debug(f"IP {ip} already banned, ignoring") | ||||
|  | ||||
|              | ||||
|     def ban_ip(self, ip): | ||||
|         """ | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Mateusz Gruszczyński
					Mateusz Gruszczyński