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
Deserialize 0.7 messages
Serialize 0.7 packet headers
Serialize 0.7 chunk headers
Serialize 0.7 messages
Deserialize 0.6 packet headers
Deserialize 0.6 chunk headers
Deserialize 0.6 messages
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

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

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/

package and release

# manual
pip install -r requirements/dev.txt
version=0.0.2
sed "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

BSD 2-Clause License

Copyright (c) 2023, ChillerDragon All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

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.2.0.tar.gz (9.2 kB view details)

Uploaded Source

Built Distribution

twnet_parser-0.2.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: twnet_parser-0.2.0.tar.gz
  • Upload date:
  • Size: 9.2 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.2.0.tar.gz
Algorithm Hash digest
SHA256 d5741c177bbeccb8f80692aaa82847f177afce1244fe9771ff7cb138eb64c10c
MD5 31edd950eba8c2fa5717d09be1973ed7
BLAKE2b-256 12d1d3c35ad7959ce01557b30e187b345e85aa0957534eed4094cb1ff0ec260f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: twnet_parser-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.0 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.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d020013b71a387ebc74fb7a41a6e6f017b52fed3ac983284cdf180c8acaecf71
MD5 8ea8ba66aee76eb58c233f9b4f235d74
BLAKE2b-256 09c6cfdfc50fdd6d262b32c1e790d5aedfdabef91b942c6c83b2cbb6070b02e1

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