mirror of
https://github.com/iio612/DEFENDER.git
synced 2026-02-14 11:44:23 +00:00
Compare commits
65 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
64f1490942 | ||
|
|
9ddb2a28b2 | ||
|
|
eacfe0d087 | ||
|
|
680a446c2c | ||
|
|
a10aa9b94e | ||
|
|
56265985f7 | ||
|
|
be36c56ceb | ||
|
|
ac332e6802 | ||
|
|
6063ceba35 | ||
|
|
2204c4fdf8 | ||
|
|
b98a20ad45 | ||
|
|
dc63df08cf | ||
|
|
a3a61c332f | ||
|
|
eeaacddbf2 | ||
|
|
39412fc1c0 | ||
|
|
e148659d00 | ||
|
|
71a7d29b08 | ||
|
|
71170baf1a | ||
|
|
1b20435b83 | ||
|
|
008dacfde6 | ||
|
|
5347c45579 | ||
|
|
63130fbc06 | ||
|
|
b27b503d78 | ||
|
|
36e3835e6c | ||
|
|
2c78025bfb | ||
|
|
979ba40c05 | ||
|
|
cea69c1580 | ||
|
|
c404cc3234 | ||
|
|
80b329dd5d | ||
|
|
f7b49c151f | ||
|
|
1ee9b7e3ff | ||
|
|
4d0087623c | ||
|
|
dc20f5ec3c | ||
|
|
110cae3b84 | ||
|
|
857cbfc85d | ||
|
|
3518589e9c | ||
|
|
e14c97de03 | ||
|
|
69360be3ad | ||
|
|
bfa90c6bd5 | ||
|
|
5c8378a0e7 | ||
|
|
e3b212ea88 | ||
|
|
0c2a350d38 | ||
|
|
1cea8d0601 | ||
|
|
652b400d5e | ||
|
|
2f8b965b59 | ||
|
|
3c043cefd8 | ||
|
|
59a75cecd8 | ||
|
|
71053437a7 | ||
|
|
7796d05206 | ||
|
|
5f2567f9e5 | ||
|
|
aaa1dd9a1a | ||
|
|
a02f2f9a26 | ||
|
|
d73adb6f0b | ||
|
|
b812e64992 | ||
|
|
9bd1f68df2 | ||
|
|
f44b08bf36 | ||
|
|
1a19e1613a | ||
|
|
cdc15b7b47 | ||
|
|
31fe9f62ec | ||
|
|
f0853e3afb | ||
|
|
6dade09257 | ||
|
|
9533b010b2 | ||
|
|
824db73590 | ||
|
|
96bf4b6f80 | ||
|
|
922336363e |
@@ -46,7 +46,7 @@ class Admin:
|
||||
return result
|
||||
|
||||
if not result:
|
||||
self.Logs.critical(f'The new nickname {newNickname} was not updated, uid = {uid}')
|
||||
self.Logs.debug(f'The new nickname {newNickname} was not updated, uid = {uid} - The Client is not an admin')
|
||||
|
||||
return result
|
||||
|
||||
@@ -63,7 +63,7 @@ class Admin:
|
||||
return result
|
||||
|
||||
if not result:
|
||||
self.Logs.critical(f'The new level {newLevel} was not updated, nickname = {nickname}')
|
||||
self.Logs.debug(f'The new level {newLevel} was not updated, nickname = {nickname} - The Client is not an admin')
|
||||
|
||||
return result
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ class Unrealircd6:
|
||||
|
||||
def __init__(self, ircInstance: 'Irc'):
|
||||
self.name = 'UnrealIRCD-6'
|
||||
self.protocol_version = 6100
|
||||
|
||||
self.__Irc = ircInstance
|
||||
self.__Config = ircInstance.Config
|
||||
@@ -158,6 +159,7 @@ class Unrealircd6:
|
||||
umodes = self.__Config.SERVICE_UMODES
|
||||
host = self.__Config.SERVICE_HOST
|
||||
service_name = self.__Config.SERVICE_NAME
|
||||
protocolversion = self.protocol_version
|
||||
|
||||
password = self.__Config.SERVEUR_PASSWORD
|
||||
link = self.__Config.SERVEUR_LINK
|
||||
@@ -169,16 +171,15 @@ class Unrealircd6:
|
||||
|
||||
self.send2socket(f":{server_id} PASS :{password}", print_log=False)
|
||||
self.send2socket(f":{server_id} PROTOCTL SID NOQUIT NICKv2 SJOIN SJ3 NICKIP TKLEXT2 NEXTBANS CLK EXTSWHOIS MLOCK MTAGS")
|
||||
# self.__Irc.send2socket(f":{sid} PROTOCTL NICKv2 VHP UMODE2 NICKIP SJOIN SJOIN2 SJ3 NOQUIT TKLEXT MLOCK SID MTAGS")
|
||||
self.send2socket(f":{server_id} PROTOCTL EAUTH={link},,,{service_name}-v{version}")
|
||||
self.send2socket(f":{server_id} PROTOCTL EAUTH={link},{protocolversion},,{service_name}-v{version}")
|
||||
self.send2socket(f":{server_id} PROTOCTL SID={server_id}")
|
||||
self.send2socket(f":{server_id} PROTOCTL BOOTED={unixtime}")
|
||||
self.send2socket(f":{server_id} SERVER {link} 1 :{info}")
|
||||
self.send2socket(f":{server_id} {nickname} :Reserved for services")
|
||||
self.send2socket(f":{server_id} UID {nickname} 1 {unixtime} {username} {host} {service_id} * {smodes} * * fwAAAQ== :{realname}")
|
||||
self.sjoin(chan)
|
||||
self.send2socket(f":{server_id} TKL + Q * {nickname} {host} 0 {unixtime} :Reserved for services")
|
||||
self.send2socket(f":{service_id} MODE {chan} {cmodes}")
|
||||
# self.send2socket(f":{service_id} MODE {chan} {umodes} {service_id}")
|
||||
|
||||
self.__Base.logs.debug(f'>> {__name__} Link information sent to the server')
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import logging
|
||||
from typing import TYPE_CHECKING
|
||||
from dataclasses import dataclass
|
||||
from unrealircd_rpc_py.Live import Live
|
||||
from unrealircd_rpc_py.Live import LiveWebsocket
|
||||
from unrealircd_rpc_py.Loader import Loader
|
||||
|
||||
if TYPE_CHECKING:
|
||||
@@ -63,15 +63,23 @@ class Jsonrpc():
|
||||
self.__load_module_configuration()
|
||||
# End of mandatory methods you can start your customization #
|
||||
|
||||
self.UnrealIrcdRpcLive: Live = Live(
|
||||
req_method='websocket',
|
||||
self.UnrealIrcdRpcLive: LiveWebsocket = LiveWebsocket(
|
||||
url=self.Config.JSONRPC_URL,
|
||||
username=self.Config.JSONRPC_USER,
|
||||
password=self.Config.JSONRPC_PASSWORD,
|
||||
callback_object_instance=self,
|
||||
callback_method_name='callback_sent_to_irc'
|
||||
callback_method_or_function_name='callback_sent_to_irc'
|
||||
)
|
||||
|
||||
if self.UnrealIrcdRpcLive.get_error.code != 0:
|
||||
self.Logs.error(self.UnrealIrcdRpcLive.get_error.code, self.UnrealIrcdRpcLive.get_error.message)
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.get_error.message}",
|
||||
channel=self.Config.SERVICE_CHANLOG
|
||||
)
|
||||
return
|
||||
|
||||
self.Rpc: Loader = Loader(
|
||||
req_method=self.Config.JSONRPC_METHOD,
|
||||
url=self.Config.JSONRPC_URL,
|
||||
@@ -79,21 +87,15 @@ class Jsonrpc():
|
||||
password=self.Config.JSONRPC_PASSWORD
|
||||
)
|
||||
|
||||
self.subscribed = False
|
||||
|
||||
if self.Rpc.Error.code != 0:
|
||||
if self.Rpc.get_error.code != 0:
|
||||
self.Logs.error(self.Rpc.get_error.code, self.Rpc.get_error.message)
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.Rpc.Error.message}",
|
||||
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.Rpc.get_error.message}",
|
||||
channel=self.Config.SERVICE_CHANLOG
|
||||
)
|
||||
|
||||
if self.UnrealIrcdRpcLive.Error.code != 0:
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.Error.message}",
|
||||
channel=self.Config.SERVICE_CHANLOG
|
||||
)
|
||||
self.subscribed = False
|
||||
|
||||
if self.ModConfig.jsonrpc == 1:
|
||||
self.Base.create_thread(self.thread_start_jsonrpc, run_once=True)
|
||||
@@ -120,7 +122,7 @@ class Jsonrpc():
|
||||
self.Base.db_execute_query(table_logs)
|
||||
return None
|
||||
|
||||
def callback_sent_to_irc(self, json_response: str):
|
||||
def callback_sent_to_irc(self, response):
|
||||
|
||||
dnickname = self.Config.SERVICE_NICKNAME
|
||||
dchanlog = self.Config.SERVICE_CHANLOG
|
||||
@@ -129,32 +131,37 @@ class Jsonrpc():
|
||||
bold = self.Config.COLORS.bold
|
||||
red = self.Config.COLORS.red
|
||||
|
||||
if json_response.result == True:
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"[{bold}{green}JSONRPC{nogc}{bold}] Event activated",
|
||||
channel=dchanlog)
|
||||
return None
|
||||
if hasattr(response, 'result'):
|
||||
if isinstance(response.result, bool) and response.result:
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"[{bold}{green}JSONRPC{nogc}{bold}] Event activated",
|
||||
channel=dchanlog)
|
||||
return None
|
||||
|
||||
level = json_response.result.level
|
||||
subsystem = json_response.result.subsystem
|
||||
event_id = json_response.result.event_id
|
||||
log_source = json_response.result.log_source
|
||||
msg = json_response.result.msg
|
||||
level = response.result.level if hasattr(response.result, 'level') else ''
|
||||
subsystem = response.result.subsystem if hasattr(response.result, 'subsystem') else ''
|
||||
event_id = response.result.event_id if hasattr(response.result, 'event_id') else ''
|
||||
log_source = response.result.log_source if hasattr(response.result, 'log_source') else ''
|
||||
msg = response.result.msg if hasattr(response.result, 'msg') else ''
|
||||
|
||||
build_msg = f"{green}{log_source}{nogc}: [{bold}{level}{bold}] {subsystem}.{event_id} - {msg}"
|
||||
|
||||
# Check if there is an error
|
||||
if self.UnrealIrcdRpcLive.get_error.code != 0:
|
||||
self.Logs.error(f"RpcLiveError: {self.UnrealIrcdRpcLive.get_error.message}")
|
||||
|
||||
self.Protocol.send_priv_msg(nick_from=dnickname, msg=build_msg, channel=dchanlog)
|
||||
|
||||
def thread_start_jsonrpc(self):
|
||||
|
||||
if self.UnrealIrcdRpcLive.Error.code == 0:
|
||||
if self.UnrealIrcdRpcLive.get_error.code == 0:
|
||||
self.UnrealIrcdRpcLive.subscribe(["all"])
|
||||
self.subscribed = True
|
||||
else:
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.Error.message}",
|
||||
msg=f"[{self.Config.COLORS.red}ERROR{self.Config.COLORS.nogc}] {self.UnrealIrcdRpcLive.get_error.message}",
|
||||
channel=self.Config.SERVICE_CHANLOG
|
||||
)
|
||||
|
||||
@@ -218,17 +225,17 @@ class Jsonrpc():
|
||||
# self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f"{logger_name} - {logger.level}")
|
||||
|
||||
for thread in self.Base.running_threads:
|
||||
if thread.getName() == 'thread_start_jsonrpc':
|
||||
if thread.name == 'thread_start_jsonrpc':
|
||||
if thread.is_alive():
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"Thread {thread.getName()} is running",
|
||||
msg=f"Thread {thread.name} is running",
|
||||
channel=dchannel
|
||||
)
|
||||
else:
|
||||
self.Protocol.send_priv_msg(
|
||||
nick_from=self.Config.SERVICE_NICKNAME,
|
||||
msg=f"Thread {thread.getName()} is not running, wait untill the process will be cleaned up",
|
||||
msg=f"Thread {thread.name} is not running, wait untill the process will be cleaned up",
|
||||
channel=dchannel
|
||||
)
|
||||
|
||||
@@ -260,8 +267,8 @@ class Jsonrpc():
|
||||
rpc = self.Rpc
|
||||
|
||||
UserInfo = rpc.User.get(uid_to_get)
|
||||
if rpc.Error.code != 0:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'{rpc.Error.message}')
|
||||
if rpc.get_error.code != 0:
|
||||
self.Protocol.send_notice(nick_from=dnickname, nick_to=fromuser, msg=f'{rpc.get_error.message}')
|
||||
return None
|
||||
|
||||
chan_list = []
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
{
|
||||
"version": "6.1.1",
|
||||
"version": "6.1.3",
|
||||
|
||||
"requests": "2.32.3",
|
||||
"psutil": "6.0.0",
|
||||
"unrealircd_rpc_py": "1.0.7",
|
||||
"unrealircd_rpc_py": "2.0.0",
|
||||
"sqlalchemy": "2.0.35",
|
||||
"faker": "30.1.0"
|
||||
}
|
||||
Reference in New Issue
Block a user