Skip to main content

Tools for working with the Photon protocol

Project description

Photon Observer

Tools for working with the Photon protocol.

Example:

import pyshark
import io
from photon_observer import PhotonLayer, FragmentBuffer, CommandType, ReliableMessage

def on_message(message: ReliableMessage):
    pass

def main():
    capture = pyshark.LiveCapture("wlp4s0", bpf_filter="udp")
    buf = FragmentBuffer()

    for p in capture.sniff_continuously():
        payload = bytes.fromhex(p.udp.payload.replace(":", ''))
        layer = PhotonLayer.unpack(io.BytesIO(payload))
        
        for cmd in layer.commands:
            if cmd.type == CommandType.SendReliableType:
                msg = cmd.reliable_message()
                on_message(msg)
            elif cmd.type == CommandType.SendUnreliableType:
                _cmd = cmd.unreliable_type()
                msg = _cmd.reliable_message()
                on_message(msg)
            elif cmd.type == CommandType.SendReliableFragmentType:
                msg = cmd.reliable_fragment()
                result = buf.offer(msg)
                if result is not None:
                    msg = result.reliable_message()
                    on_message(msg)
            else:
                continue

PS

Additional thanks to @hmadison for his photon_spectator package

License

This project is licensed under MIT. Contributions to this project are accepted under the same license.

Project details


Release history Release notifications | RSS feed

This version

0.1

Download files

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

Source Distribution

photon_observer-0.1.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

photon_observer-0.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file photon_observer-0.1.tar.gz.

File metadata

  • Download URL: photon_observer-0.1.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/4.0.1 CPython/3.11.4

File hashes

Hashes for photon_observer-0.1.tar.gz
Algorithm Hash digest
SHA256 12f7bf3f893d061c2e829a559303bc5e88bc58edc4965543a8bf7a165517c34f
MD5 c08b7844ef52b1452dc9cbff577bd1a6
BLAKE2b-256 af7503dd869a46cb14ff547e27e80bfeb4c90ef26612687ce0314b41d8e14179

See more details on using hashes here.

File details

Details for the file photon_observer-0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for photon_observer-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 92381bffa31410d0bdfa974c07e466f139cf3a4f254a38d6197d17107533e8f4
MD5 4e9cbe0d56a09c182fdd56d5d0e1fd11
BLAKE2b-256 9cdfc522a62206fe5f0e8acb8b88be4e7e9db92a05852689f4859b0f3ee83747

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