Compare commits

..

No commits in common. "a057004cd2aac9e59ae2ad5a097afaf15e801418" and "c1c18f4f3b7a5960d92360487c01856f817b8339" have entirely different histories.

3 changed files with 10 additions and 12 deletions

View File

@ -15,13 +15,10 @@ BeamingDrive Multiplayer (BeamMP) server compatible with BeamMP clients.
- [x] Connecting to the world - [x] Connecting to the world
- [x] Chat - [x] Chat
- [ ] ABG: (compressed data) - [ ] ABG: (compressed data)
- [x] Decompress data - [ ] Decompress data
- [ ] Vehicle data - [ ] Vehicle data
- [ ] Players synchronizations
- [ ] UDP Server part: - [ ] UDP Server part:
- [ ] Players synchronizations - [ ] Players synchronizations
- [ ] Ping
- [ ] Player counter
- [x] Additional: - [x] Additional:
- [x] Events System - [x] Events System
- [x] Plugins support - [x] Plugins support

View File

@ -5,7 +5,6 @@
# Licence: FPA # Licence: FPA
# (c) kuitoi.su 2023 # (c) kuitoi.su 2023
import asyncio import asyncio
import zlib
from core import utils from core import utils
from .tcp_server import TCPServer from .tcp_server import TCPServer
@ -71,6 +70,7 @@ class Client:
# if not self.is_disconnected(): # if not self.is_disconnected():
# self.log.debug(f"Client with {self.nick}({self.cid}) disconnected") # self.log.debug(f"Client with {self.nick}({self.cid}) disconnected")
# return b"" # return b""
header = await self.reader.read(4) # header: 4 bytes header = await self.reader.read(4) # header: 4 bytes
int_header = 0 int_header = 0
@ -88,16 +88,17 @@ class Client:
return b"" return b""
data = await self.reader.read(101 * MB) data = await self.reader.read(101 * MB)
self.log.debug(f"header: `{header}`; int_header: `{int_header}`; data: `{data}`;")
if len(data) != int_header: if len(data) != int_header:
self.log.debug(f"WARN Expected to read {int_header} bytes, instead got {len(data)}") self.log.debug(f"WARN Expected to read {int_header} bytes, instead got {len(data)}")
# TODO: ABG: DeComp(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 = data[len(abg):]
self.log.debug(f"ABG: {data}") return b""
return data # return DeComp(Data);
self.log.debug(f"header: `{header}`; int_header: `{int_header}`; data: `{data}`;")
return data return data
async def sync_resources(self): async def sync_resources(self):

View File

@ -27,10 +27,10 @@ class TCPServer:
self.log.debug(f"recv1 data: {data}") self.log.debug(f"recv1 data: {data}")
if len(data) > 50: if len(data) > 50:
await client.kick("Too long data") await client.kick("Too long data")
return False, None return
if "VC2.0" not in data.decode("utf-8"): if "VC2.0" not in data.decode("utf-8"):
await client.kick("Outdated Version.") await client.kick("Outdated Version.")
return False, None return
else: else:
await client.tcp_send(b"A") # Accepted client version await client.tcp_send(b"A") # Accepted client version
@ -38,7 +38,7 @@ class TCPServer:
self.log.debug(f"recv2 data: {data}") self.log.debug(f"recv2 data: {data}")
if len(data) > 50: if len(data) > 50:
await client.kick("Invalid Key (too long)!") await client.kick("Invalid Key (too long)!")
return False, None return
client.key = data.decode("utf-8") client.key = data.decode("utf-8")
async with aiohttp.ClientSession() as session: async with aiohttp.ClientSession() as session:
url = 'https://auth.beammp.com/pkToUser' url = 'https://auth.beammp.com/pkToUser'