mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-13 11:14:23 +00:00
Fix rehash command. adding security to force quite defender when a asyncio is blocking the system.
This commit is contained in:
@@ -17,6 +17,7 @@ class MClone(MainModel):
|
||||
hostname: str = 'localhost'
|
||||
umodes: str = None
|
||||
remote_ip: str = '127.0.0.1'
|
||||
group: str = 'Default'
|
||||
group: str = 'Default',
|
||||
geoip: str = 'XX'
|
||||
|
||||
# DB_CLONES: list[MClone] = []
|
||||
@@ -28,7 +28,7 @@ async def coro_connect_clones(uplink: 'Clone',
|
||||
break
|
||||
|
||||
if not clone.connected:
|
||||
await uplink.ctx.Irc.Protocol.send_uid(clone.nickname, clone.username, clone.hostname, clone.uid, clone.umodes, clone.vhost, clone.remote_ip, clone.realname, print_log=False)
|
||||
await uplink.ctx.Irc.Protocol.send_uid(clone.nickname, clone.username, clone.hostname, clone.uid, clone.umodes, clone.vhost, clone.remote_ip, clone.realname, clone.geoip, print_log=False)
|
||||
await uplink.ctx.Irc.Protocol.send_join_chan(uidornickname=clone.uid, channel=uplink.ctx.Config.CLONE_CHANNEL, password=uplink.ctx.Config.CLONE_CHANNEL_PASSWORD, print_log=False)
|
||||
|
||||
await asyncio.sleep(interval)
|
||||
|
||||
@@ -103,6 +103,17 @@ def generate_ipv4_for_clone(faker_instance: 'Faker', auto: bool = True) -> str:
|
||||
"""
|
||||
return faker_instance.ipv4_private() if auto else '127.0.0.1'
|
||||
|
||||
def generate_country_code_for_clone(faker_instance: 'Faker') -> str:
|
||||
"""Generate the alpha-2 country code for clone
|
||||
|
||||
Args:
|
||||
faker_instance (Faker): The Faker Instance
|
||||
|
||||
Returns:
|
||||
str: The Country Code
|
||||
"""
|
||||
return faker_instance.country_code('alpha-2')
|
||||
|
||||
def generate_hostname_for_clone(faker_instance: 'Faker') -> str:
|
||||
"""Generate hostname for clone
|
||||
|
||||
@@ -143,6 +154,8 @@ def create_new_clone(uplink: 'Clone', faker_instance: 'Faker', group: str = 'Def
|
||||
hostname = generate_hostname_for_clone(faker)
|
||||
vhost = generate_vhost_for_clone(faker)
|
||||
|
||||
geoip = generate_country_code_for_clone(faker)
|
||||
|
||||
checkNickname = uplink.Clone.nickname_exists(nickname)
|
||||
checkUid = uplink.Clone.uid_exists(uid=uid)
|
||||
|
||||
@@ -167,7 +180,8 @@ def create_new_clone(uplink: 'Clone', faker_instance: 'Faker', group: str = 'Def
|
||||
remote_ip=decoded_ip,
|
||||
vhost=vhost,
|
||||
group=group,
|
||||
channels=[]
|
||||
channels=[],
|
||||
geoip=geoip
|
||||
)
|
||||
|
||||
uplink.Clone.insert(clone)
|
||||
|
||||
@@ -227,6 +227,7 @@ async def coro_psutil_scan(uplink: 'Defender'):
|
||||
for user in uplink.Schemas.DB_PSUTIL_USERS:
|
||||
result = await uplink.ctx.Base.create_thread_io(uplink.mod_utils.action_scan_client_with_psutil, uplink, user)
|
||||
list_to_remove.append(user)
|
||||
|
||||
if not result:
|
||||
continue
|
||||
|
||||
|
||||
@@ -534,8 +534,14 @@ def action_scan_client_with_abuseipdb(uplink: 'Defender', user_model: 'MUser') -
|
||||
'Accept': 'application/json',
|
||||
'Key': uplink.abuseipdb_key
|
||||
}
|
||||
|
||||
response = sess.request(method='GET', url=url, headers=headers, params=querystring, timeout=uplink.timeout)
|
||||
try:
|
||||
response = sess.request(method='GET', url=url, headers=headers, params=querystring, timeout=uplink.timeout)
|
||||
except (requests.exceptions.ReadTimeout, requests.exceptions.ConnectTimeout) as err:
|
||||
uplink.ctx.Logs.error(f"Time-out Error: {err}")
|
||||
return None
|
||||
except Exception as e:
|
||||
uplink.ctx.Logs.error(f"Time-out Error: {e}")
|
||||
return None
|
||||
|
||||
if response.status_code != 200:
|
||||
uplink.ctx.Logs.warning(f'status code = {str(response.status_code)}')
|
||||
|
||||
@@ -126,8 +126,8 @@ class Test(IModule):
|
||||
await self.ctx.Irc.Protocol.send_priv_msg(nick_from=dnickname, msg=f"This is private message to the sender ...", channel=c.name)
|
||||
|
||||
# How to update your module configuration
|
||||
self.update_configuration('param_exemple2', 7)
|
||||
self.update_configuration('param_exemple1', 'my_value')
|
||||
await self.update_configuration('param_exemple2', 7)
|
||||
await self.update_configuration('param_exemple1', 'my_value')
|
||||
|
||||
# Log if you want the result
|
||||
self.ctx.Logs.debug(f"Test logs ready")
|
||||
|
||||
Reference in New Issue
Block a user