Frame Streams implementation in Python
Frame Streams is a lightweight, binary-clean protocol that allows for the transport of arbitrarily encoded data payload sequences with minimal framing overhead.
This package provides a pure Python implementation based on https://github.com/farsightsec/fstrm/.
Installation
This module can be installed from pypi website
pip install fstrm
Example
The example shows how to read raw data and decode-it with the fstrsm library.
import fstrm
import asyncio
class FstrmServerProtocol(asyncio.Protocol):
def __init__(self, handshake, data_recv, content_type=b"plaintext"):
self.fstrm = fstrm.FstrmCodec()
self.content_type = content_type
self.data_recv = data_recv
self.handshake = handshake
self.handshake_accept_done = False
def connection_made(self, transport):
self.transport = transport
def data_received(self, data):
if not self.handshake.done():
if not self.handshake_accept_done:
if self.fstrm.is_ctrlready(data):
self.transport.write(self.fstrm.encode_ctrlaccept(self.content_type))
self.handshake_accept_done = True
else:
if self.fstrm.is_ctrlstart(data):
self.handshake.set_result(True)
else:
payload = self.fstrm.is_data(data)
# do someting with the payload...
if payload:
self.data_recv.set_result(payload)
class FstrmClientProtocol(asyncio.Protocol):
def __init__(self, handshake, content_type=b"plaintext"):
self.fstrm = fstrm.FstrmCodec()
self.content_type = content_type
self.handshake = handshake
self.transport = None
def connection_made(self, transport):
self.transport = transport
self.transport.write(self.fstrm.encode_ctrlready(self.content_type))
def data_received(self, data):
if not self.handshake.done():
if self.fstrm.is_ctrlaccept(data):
self.transport.write(self.fstrm.encode_ctrlstart(self.content_type))
self.handshake.set_result(True)
def send_data(self, data):
payload = self.fstrm.encode_data(data)
self.transport.write(payload)
async def run():
loop = asyncio.get_running_loop()
# Create server and client
data_recv = loop.create_future()
hanshake_server = loop.create_future()
server = await loop.create_server(lambda: FstrmServerProtocol(hanshake_server, data_recv), 'localhost', 8000)
hanshake_client = loop.create_future()
transport, client = await loop.create_connection(lambda: FstrmClientProtocol(hanshake_client), 'localhost', 8000)
# check handshake
try:
await asyncio.wait_for(hanshake_server, timeout=5)
except asyncio.TimeoutError:
raise Exception("handshake server failed")
try:
await asyncio.wait_for(hanshake_client, timeout=0.5)
except asyncio.TimeoutError:
raise Exception("handshake client failed")
# ok, the client send some data
data = b"some data..."
client.send_data(data)
# wait data on server side
try:
await asyncio.wait_for( data_recv, timeout=0.5)
except asyncio.TimeoutError:
raise Exception("data expected but failed")
# Shut down server and client
server.close()
transport.close()
if __name__ == "__main__":
asyncio.run(run())
Metadata
Release files for fstrm 0.6.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| fstrm-0.6.2.tar.gz | 4.8 kB | With provenance | Details for fstrm-0.6.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| fstrm-0.6.2-py3-none-any.whl | Python 3 | none | any | Details for fstrm-0.6.2-py3-none-any.whl |
Total release size: 9.9 kB
Release files / fstrm-0.6.2.tar.gz
| Download URL | fstrm-0.6.2.tar.gz |
|---|---|
| Size | 4.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
d1d456e9e1f1b9435b2bb2fa1115fafdb829daab61332cc14bf200a70796211e
|
|
BLAKE2b-256 checksum How to use checksums |
2b46fd579759ba8f3fd3cf2455bf187d23bfc8372f38ea6e34f6231318e36531
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 25, 2026.
Transparency logRelease files / fstrm-0.6.2-py3-none-any.whl
| Download URL | fstrm-0.6.2-py3-none-any.whl |
|---|---|
| Size | 5.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
11e28e00383d2c4b8a9e7b87d6292e4bb6290ed22664972dd4d6ad6575d413a6
|
|
BLAKE2b-256 checksum How to use checksums |
4391f438953bac75630066141cc5b964ff5b2f40bacb42a0255c6bbb92c0d0ab
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 25, 2026.
Transparency logSecurity for fstrm 0.6.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for fstrm-0.6.2.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 25, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.