This commit is contained in:
adator85
2024-03-24 01:01:18 +01:00
parent 7068d88168
commit 19b7f85ec7
4 changed files with 78 additions and 39 deletions

View File

@@ -1,4 +1,4 @@
import time, threading, os, random, socket, hashlib
import time, threading, os, random, socket, hashlib, ipaddress
from datetime import datetime
from sqlalchemy import create_engine, Engine, Connection, CursorResult
from sqlalchemy.sql import text
@@ -179,7 +179,7 @@ class Base:
"""Methode qui supprime les timers qui ont finis leurs job
"""
try:
self.__debug(f"=======> Checking for Timers to stop")
# self.__debug(f"=======> Checking for Timers to stop")
# print(f"{self.running_timers}")
for timer in self.running_timers:
if not timer.is_alive():
@@ -196,7 +196,7 @@ class Base:
"""Methode qui supprime les threads qui ont finis leurs job
"""
try:
self.__debug(f"=======> Checking for Threads to stop")
# self.__debug(f"=======> Checking for Threads to stop")
for thread in self.running_threads:
if thread.getName() != 'heartbeat':
if not thread.is_alive():
@@ -209,7 +209,7 @@ class Base:
def garbage_collector_sockets(self) -> None:
self.__debug(f"=======> Checking for Sockets to stop")
# self.__debug(f"=======> Checking for Sockets to stop")
for soc in self.running_sockets:
while soc.fileno() != -1:
self.__debug(soc.fileno())
@@ -358,6 +358,17 @@ class Base:
except TypeError:
return value
def is_valid_ip(self, ip_to_control:str) -> bool:
try:
if ip_to_control in self.Config.WHITELISTED_IP:
return False
ipaddress.ip_address(ip_to_control)
return True
except ValueError:
return False
def get_random(self, lenght:int) -> str:
"""
Retourn une chaîne aléatoire en fonction de la longueur spécifiée.