Compare commits

...

3 Commits

Author SHA1 Message Date
a057004cd2 Decompress data 2023-07-08 18:57:18 +03:00
f7defaed0c Minor fixes 2023-07-08 18:46:05 +03:00
abd4fb60c1 Minor fixes 2023-07-08 13:10:37 +03:00
3 changed files with 12 additions and 10 deletions

View File

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

View File

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

View File

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