Skip to main content

A teeworlds network protocol library, designed according to sans I/O (http://sans-io.readthedocs.io/) principles

Project description

A teeworlds network protocol library, designed according to sans I/O (http://sans-io.readthedocs.io/) principles

THIS LIBRARY IS IN EARLY DEVELOPMENT

Do not get bamboozled by the mature looking readme!

This project is not in a very usable state yet. It is in very early development!

APIs might change and many essential features are missing!


install

pip install twnet_parser

sample usage

import twnet_parser.packet
packet = twnet_parser.packet.parse7(b'\x04\x0a\x00\xcf\x2e\xde\x1d\04') # 0.7 close

print(packet) # => <class: 'TwPacket'>: {'version': '0.7', 'header': <class: 'Header'>, 'messages': [<class: 'CtrlMessage'>]}
print(packet.header) # => <class: 'Header'>: {'flags': <class: 'PacketFlags7, 'size': 0, 'ack': 10, 'token': b'\xcf.\xde\x1d', 'num_chunks': 0}
print(packet.header.flags) # => <class: 'PacketFlags7'>: {'control': True, 'resend': False, 'compression': False, 'connless': False}
for msg in packet.messages:
    print(msg.message_name) # => close

Features

Feature Status
Deserialize 0.7 packet headers :heavy_check_mark:
Deserialize 0.7 chunk headers :heavy_check_mark:
Deserialize 0.7 messages 80%
Deserialize 0.7 snapshots
Serialize 0.7 packet headers :heavy_check_mark:
Serialize 0.7 chunk headers
Serialize 0.7 messages 80%
Deserialize 0.6 packet headers
Deserialize 0.6 chunk headers
Deserialize 0.6 messages
Deserialize 0.6 snapshots
Serialize 0.6 packet headers
Serialize 0.6 chunk headers
Serialize 0.6 messages

Non-Features (also not planned for this library)

Feature Status Where to find it
Networking :x: TODO: link if someone implemented it on top
Protocol version detection :x: TODO: link if someone implemented it on top
Track sequence number state :x: TODO: link if someone implemented it on top
Track connection state :x: TODO: link if someone implemented it on top

Look elsewhere for these features. Or use this library to implement them on top.

This project is intentionally only covering parsing the protocol. Not fully implemeting a state machine of the protocol. Or a fully working client / server software.

If you want to build something with this library you do have to understand how the protocol works and when the client and server have to send what.

This protocol documentation should get you started to understand the basics.

development setup

git clone https://gitlab.com/teeworlds-network/twnet_parser
cd twnet_parser
python -m venv venv
source venv/bin/activate
pip install -r requirements/dev.txt

tests and linting

# dev dependencies
pip install -r requirements/dev.txt

# run unit tests
pytest .

# run style linter
pylint src/

# run type checker
mypy src/

# or use the bundle script that runs all tests
./scripts/run_tests.sh

package and release

# manual
pip install -r requirements/dev.txt
version=0.0.2
sed -i "s/^version =.*/version = $version/" setup.cfg
python -m build
git tag -a "v$version" -m "# version $version"
python -m twine upload dist/*

# or use the interactive convience script
./scripts/release.sh

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

twnet_parser-0.4.0.tar.gz (38.9 kB view details)

Uploaded Source

Built Distribution

twnet_parser-0.4.0-py3-none-any.whl (57.4 kB view details)

Uploaded Python 3

File details

Details for the file twnet_parser-0.4.0.tar.gz.

File metadata

  • Download URL: twnet_parser-0.4.0.tar.gz
  • Upload date:
  • Size: 38.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for twnet_parser-0.4.0.tar.gz
Algorithm Hash digest
SHA256 12892c81cd2cffa9dd5a67e3ba4b1084318d3b751855595b1b865c950aede351
MD5 97912fbf62711638aae22822de607b59
BLAKE2b-256 facd2186144bcbb591c2c06968804f01cbab63b4467d4fde188ba503e6394b37

See more details on using hashes here.

File details

Details for the file twnet_parser-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: twnet_parser-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 57.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.10

File hashes

Hashes for twnet_parser-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3c56385caedf6bcd142b5adaf3e544d470dede8e14501a42efc2ddc723d17443
MD5 0ef3f20c00066c66f13299c415138bd4
BLAKE2b-256 c0f428ddc5383d419eb2ddf53b415a07107f464f15ea5057fae3747726b5a814

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page