mirror of
https://github.com/kuitoi/kuitoi-Server.git
synced 2025-08-18 00:35:36 +00:00
Compare commits
No commits in common. "de91d075b4627ff754770b4f2b0d62883929a9b9" and "7e0c50a04e15a3c33b2051484f87d443d6acffe1" have entirely different histories.
de91d075b4
...
7e0c50a04e
@ -194,13 +194,7 @@ class Client:
|
|||||||
async def _recv(self, one=False):
|
async def _recv(self, one=False):
|
||||||
while self.__alive:
|
while self.__alive:
|
||||||
try:
|
try:
|
||||||
header = b""
|
header = await self.__reader.read(4)
|
||||||
while len(header) < 4 and self.__alive:
|
|
||||||
h = await self.__reader.read(4)
|
|
||||||
if not h:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
header += h
|
|
||||||
|
|
||||||
int_header = int.from_bytes(header, byteorder='little', signed=True)
|
int_header = int.from_bytes(header, byteorder='little', signed=True)
|
||||||
|
|
||||||
@ -225,14 +219,9 @@ class Client:
|
|||||||
self.__packets_queue.append(None)
|
self.__packets_queue.append(None)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
data = b""
|
data = await self.__reader.read(int_header)
|
||||||
while len(data) < int_header and self.__alive:
|
|
||||||
buffer = await self.__reader.read(int_header - len(data))
|
|
||||||
if not buffer:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
data += buffer
|
|
||||||
|
|
||||||
|
# self.log.debug(f"int_header: {int_header}; data: `{data}`;")
|
||||||
abg = b"ABG:"
|
abg = b"ABG:"
|
||||||
if len(data) > len(abg) and data.startswith(abg):
|
if len(data) > len(abg) and data.startswith(abg):
|
||||||
data = zlib.decompress(data[len(abg):])
|
data = zlib.decompress(data[len(abg):])
|
||||||
|
@ -217,22 +217,6 @@ class Core:
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Error in heartbeat: {e}")
|
self.log.error(f"Error in heartbeat: {e}")
|
||||||
|
|
||||||
async def kick_cmd(self, args):
|
|
||||||
if not len(args) > 0:
|
|
||||||
return "\nUsage: kick <nick>|:<id> [reason]\nExamples:\n\tkick admin bad boy\n\tkick :0 bad boy"
|
|
||||||
reason = "kicked by console."
|
|
||||||
if len(args) > 1:
|
|
||||||
reason = " ".join(args[1:])
|
|
||||||
cl = args[0]
|
|
||||||
if cl.startswith(":") and cl[1:].isdigit():
|
|
||||||
client = self.get_client(cid=int(cl[1:]))
|
|
||||||
else:
|
|
||||||
client = self.get_client(nick=cl)
|
|
||||||
if client:
|
|
||||||
await client.kick(reason)
|
|
||||||
else:
|
|
||||||
return "Client not found."
|
|
||||||
|
|
||||||
async def main(self):
|
async def main(self):
|
||||||
self.tcp = self.tcp(self, self.server_ip, self.server_port)
|
self.tcp = self.tcp(self, self.server_ip, self.server_port)
|
||||||
self.udp = self.udp(self, self.server_ip, self.server_port)
|
self.udp = self.udp(self, self.server_ip, self.server_port)
|
||||||
@ -240,7 +224,6 @@ class Core:
|
|||||||
"list",
|
"list",
|
||||||
lambda x: f"Players list: {self.get_clients_list(True)}"
|
lambda x: f"Players list: {self.get_clients_list(True)}"
|
||||||
)
|
)
|
||||||
console.add_command("kick", self.kick_cmd)
|
|
||||||
|
|
||||||
pl_dir = "plugins"
|
pl_dir = "plugins"
|
||||||
self.log.debug("Initializing PluginsLoaders...")
|
self.log.debug("Initializing PluginsLoaders...")
|
||||||
|
@ -100,8 +100,8 @@ class UDPServer(asyncio.DatagramTransport):
|
|||||||
await asyncio.sleep(0.2)
|
await asyncio.sleep(0.2)
|
||||||
|
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
# self.run = False
|
self.run = False
|
||||||
# self.Core.run = False
|
self.Core.run = False
|
||||||
self.log.error(f"Cannot bind port or other error: {e}")
|
self.log.error(f"Cannot bind port or other error: {e}")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.log.error(f"Error: {e}")
|
self.log.error(f"Error: {e}")
|
||||||
|
@ -7,7 +7,6 @@
|
|||||||
# Licence: FPA
|
# Licence: FPA
|
||||||
# (c) kuitoi.su 2023
|
# (c) kuitoi.su 2023
|
||||||
import builtins
|
import builtins
|
||||||
import inspect
|
|
||||||
import logging
|
import logging
|
||||||
from typing import AnyStr
|
from typing import AnyStr
|
||||||
|
|
||||||
@ -243,11 +242,7 @@ class Console:
|
|||||||
self.log(text)
|
self.log(text)
|
||||||
command_object = self.__func.get(cmd)
|
command_object = self.__func.get(cmd)
|
||||||
if command_object:
|
if command_object:
|
||||||
func = command_object['f']
|
out = command_object['f'](cmd_s[1:])
|
||||||
if inspect.iscoroutinefunction(func):
|
|
||||||
out = await func(cmd_s[1:])
|
|
||||||
else:
|
|
||||||
out = func(cmd_s[1:])
|
|
||||||
if out:
|
if out:
|
||||||
self.log(out)
|
self.log(out)
|
||||||
else:
|
else:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user