bta-proxy/bta_proxy/dpi.py

54 lines
1.6 KiB
Python
Raw Normal View History

2023-08-25 21:49:10 +03:00
from asyncio.queues import Queue
2023-08-26 01:12:19 +03:00
import time
2023-08-25 21:49:10 +03:00
from bta_proxy.datainputstream import AsyncDataInputStream
2023-08-25 23:11:36 +03:00
from bta_proxy.packets import *
2023-08-25 21:49:10 +03:00
async def inspect_client(queue: Queue, addr: tuple[str, int]):
dis = AsyncDataInputStream(queue)
2023-08-26 01:12:19 +03:00
last_time = time.time()
2023-08-25 21:49:10 +03:00
while True:
pkt = await Packet.read_packet(dis)
2023-08-26 01:12:19 +03:00
now = time.time()
delta = now - last_time
last_time = now
2023-08-25 23:11:36 +03:00
match pkt.packet_id:
case Packet10Flying.packet_id:
continue
case Packet11PlayerPosition.packet_id:
continue
case Packet12PlayerLook.packet_id:
continue
case Packet13LookMove.packet_id:
continue
case Packet255KickDisconnect.packet_id:
break
case _:
2023-08-26 01:12:19 +03:00
print(f"C {delta*1000:+8.1f}ms {pkt}")
2023-08-25 21:49:10 +03:00
async def inspect_server(queue: Queue, addr: tuple[str, int]):
dis = AsyncDataInputStream(queue)
2023-08-26 01:12:19 +03:00
last_time = time.time()
2023-08-25 21:49:10 +03:00
while True:
pkt = await Packet.read_packet(dis)
2023-08-26 01:12:19 +03:00
now = time.time()
delta = now - last_time
last_time = now
match pkt.packet_id:
case Packet50PreChunk.packet_id:
continue
case Packet51MapChunk.packet_id:
continue
case Packet31RelEntityMove.packet_id:
continue
case Packet32EntityLook.packet_id:
continue
case Packet33RelEntityMoveLook.packet_id:
continue
case _:
print(f"S {delta*1000:+8.1f}ms {pkt}")