/rakpy

Pythonic implementation of the RakNet protocol

Primary LanguagePython

rakpy

Pythonic implementation of the RakNet protocol WORK IN PROGRESS

Status

Build Status Code Coverage Code Quality Chat

Compatibility

Python 3.5, 3.4, 3.3 Python 2.7

Project goals

  • Provide a pythonic interface (other projects exist but they feel like Java or PHP)
  • Provide a decent test suite
  • Parts of the code are generated from YAML files (so we can move fast by tweaking YAML, and we can share this with other projects)
  • Cover enough to implement a MCPE server

Usage

Decoding packets

In [1]: from rakpy.protocol import decode_packet

In [2]: buffer = b"\x01\x00\ (...) \x23\xa3"  # data from UDP packet

In [3]: packet = decode_packet(buffer)

In [4]: print packet
UnconnectedPing(time=193351, client_guid=1450258689827747)

In [5]: packet.time
193351

In [6]: packet.client_guid
1450258689827747

Encoding packets (not implemented yet)

In [1]: from rakpy.protocol.packets import UnconnectedPing

In [2]: packet = UnconnectedPong(ping_time=193351, server_guid=1450258689827742)

In [3]: packet.encode()
b"\x1c\x00\ (...) \x23\xa3"  # you can send this over UDP