diff --git a/app/classes/shared/main_controller.py b/app/classes/shared/main_controller.py index 41773c41..27104b62 100644 --- a/app/classes/shared/main_controller.py +++ b/app/classes/shared/main_controller.py @@ -93,9 +93,16 @@ class Controller: if remote: remote["names"].append(username) remote["attempts"] += 1 + remote["times"].append(datetime.now().strftime("%d/%m/%Y %H:%M:%S")) self.auth_tracker[str(remote_ip)] = remote else: - self.auth_tracker[str(remote_ip)] = {"names": [username], "attempts": 1} + self.auth_tracker[str(remote_ip)] = { + "names": [username], + "attempts": 1, + "times": [datetime.now().strftime("%d/%m/%Y %H:%M:%S")], + } + + def write_auth_tracker(self): with open( os.path.join(os.path.curdir, "logs", "auth_tracker.log"), "w", diff --git a/app/classes/shared/tasks.py b/app/classes/shared/tasks.py index 0402c587..ff20e7ec 100644 --- a/app/classes/shared/tasks.py +++ b/app/classes/shared/tasks.py @@ -201,6 +201,13 @@ class TasksManager: id="update_watcher", start_date=datetime.datetime.now(), ) + self.scheduler.add_job( + self.controller.write_auth_tracker, + "interval", + minutes=5, + id="auth_tracker_write", + start_date=datetime.datetime.now(), + ) # self.scheduler.add_job( # self.scheduler.print_jobs, "interval", seconds=10, id="-1" # )