4. Transport Subsystem (fleetmesh_node.transport)
The fleetmesh_node.transport package implements the multi-rung transport ladder.
Traffic automatically ascends through available rungs based on peer capabilities,
firewall conditions, and cryptographic policies.
4.1. Transport Ladder Architecture
The Transport Router evaluates outbound routes across a prioritized ladder sorted by rank (lowest rank is attempted first):
FIPS Rung (Rank 5, mTLS / Datagram): Hardware-enforced mutual authentication using NIST-approved curves and FIPS 140-3 validated cryptography.
Iroh Rung (Rank 10, QUIC): Direct, encrypted point-to-point datagrams with ALPN negotiation, DERP relay hole punching, and high throughput.
Rhio Rung (Rank 12, NATS JetStream): Micro-datacenter cluster synchronization delivering through local Unix domain socket IPC to the Rhio sidecar daemon.
P2Panda Rung (Rank 15, Append-Only Operation Chains): Peer-to-peer delivery wrapping DIDComm messages into signed p2panda operations published to local append-only logs and synced peers.
Relay Rung (Rank 30, WebSocket): Outbound-only fallback over public or private Nostr relays. Guarantees reachability behind strict firewalls and NATs.
4.2. Transport Router
The router: TransportRouter, the ladder from direct rungs down to the gift-wrap rung.
Separate from the rungs because it is the only module that knows about all of them, and the direct rungs import from const.py without ever importing the router back.
- class fleetmesh_node.transport.router.RefusalRow[source]
Bases:
TypedDictA direct rung’s refusal of one peer, for the ladder’s telemetry.
- class fleetmesh_node.transport.router.LadderHealthRow[source]
Bases:
TypedDictCircuit breaker and availability status of one transport rung.
- class fleetmesh_node.transport.router.NullTransport[source]
Bases:
objectA null transport rung used when Nostr is disabled in configuration.
- class fleetmesh_node.transport.router.TransportRouter[source]
Bases:
FipsRungMixinThe multi-transport router and ladder negotiator.
Implements TransportProtocol across all active transports: - fips-native: datagram flows through the fips sidecar (mesh-encrypted) - iroh: EXPERIMENTAL / unauthenticated. Direct TCP stream or the
iroh_live UDP framing; the wire itself is neither encrypted nor authenticated, only the DIDComm JWE inside is. Opt-in: built only when config names an iroh endpoint (see __init__).
libp2p: stream through the p2p sidecar, when the node builds one
nostr: NIP-59 gift-wrapped DIDComm over relays (Kinds 21059 / 1059)
The ladder in send() ranks fips-native, iroh, libp2p, nostr by preference; the rank says which is tried first, not which is safer. Every rung is held to the same envelope rule (didcomm_inbound).
Performs dynamic ladder negotiation (fleetmesh_core.storage.replication.negotiate) based on peer descriptor endpoints, automatically falling back down the ladder to Nostr when direct streams fail or are unavailable.
- __init__(keystore, peers, relay_urls=(), endpoints=None, clock=None, timeout=15.0, seen_store=None, ack_store=None, iroh_host='127.0.0.1', iroh_port=0, sidecar_dir=None, enable_iroh=None, iroh_mode='stream', fips_sock_path=None, enable_fips=True, fips_port=11801, fips_client=None, enable_nostr=True)[source]
- Parameters:
keystore (Any)
peers (Any)
timeout (float)
seen_store (tuple[Callable[[str], bool], Callable[[str, int], None]] | None)
ack_store (Any | None)
iroh_host (str)
iroh_port (int)
sidecar_dir (str | None)
enable_iroh (bool | None)
iroh_mode (str)
fips_sock_path (str | None)
enable_fips (bool)
fips_port (int)
fips_client (Any | None)
enable_nostr (bool)
- Return type:
None
- transports: MutableMapping[str, Any]
- refusals_log: Deque[RefusalRow]
- guard: InboundGuard
- circuit_breakers: dict[str, CircuitBreaker]
- rungs: list[RungProtocol]
- register_rung(rung)[source]
Register a dynamic transport rung into the ladder.
- Parameters:
rung (RungProtocol)
- Return type:
None
- add_rung(rung)[source]
Alias for register_rung to satisfy ProtocolManager.
- Parameters:
rung (RungProtocol)
- Return type:
None
- unregister_rung(name)[source]
Remove a transport rung by name from the ladder.
- Parameters:
name (str)
- Return type:
RungProtocol | None
- get_rung(name)[source]
Retrieve a registered transport rung by name.
- Parameters:
name (str)
- Return type:
RungProtocol | None
- property health: Mapping[str, RelayHealthRow]
- rung_health()[source]
Every rung’s own report, keyed by rung name; a rung whose daemon is not built is absent. The one view of the ladder’s state.
- property ladder_health: dict[str, LadderHealthRow]
Circuit breaker and availability status across transport rungs.
- property cooldown: RelayCooldown | None
which relays are being rested after a rate-limit and until when. None for a relay-rung double that keeps none.
- Type:
The relay rung’s cooldown ledger
- deliver_direct(scheme, payload, wrap_id, origin=None)[source]
One payload off a direct rung (fips-native, libp2p): a JWE, or nothing.
Returns None when the message was queued or was an empty ping, else the reason it was dropped, which is also recorded.
The daemon behind a direct rung proves for itself who the other end of a flow or stream is, but this node never sees that proof - it reads a payload off a local socket, and on a cluster daemon, a mock, or a shared host anyone with the socket can write one. So the payload is treated exactly as a stream off the internet is: it must be a JWE this node can open, and the sender is whoever the agreement proves, never the from field. A plaintext frame on this path used to arrive as an authenticated message from anyone it cared to name, and resolved whatever request() was waiting for; now it is a drop with a reason, and nothing else.
origin, when a sidecar reports one, is the raw Ed25519 transport key hex the remote stream authenticated with. It is a hint, not the sender: the sender’s descriptor publishes its transport key, and a message whose proven sender advertises a different one did not come from that sender’s node, so it is dropped rather than delivered as something it is not.
Nothing in here may raise: the reader loop ends on any exception, which would let one malformed frame take the flow down.
- set_send_interceptor(interceptor)[source]
Register a send interceptor (e.g. for cluster partition and loss simulation).
- set_rung_interceptor(interceptor)[source]
Register a per-rung delivery interceptor (e.g. for directed partition and cascade testing).
- send(message, to_pubkey, anonymous=False, stored=False)[source]
Dispatch a message over the top negotiated transport ladder rung.
stored=True requires store-and-forward relays (NIP-59 Kind 1059). Live messages negotiate fips-native or iroh if mutually supported, falling back down the ladder to relay gift-wraps if dialing fails.
- request(message, to_pubkey, timeout=30.0, anonymous=False)[source]
Send and wait for the reply threaded on this message’s id.
- converse(message, to_pubkey, thid, timeout=30.0, anonymous=False)[source]
Send and wait for next message on thread across any active transport.
4.3. Ladder State Machine
Per-rung circuit breaker and the rung base class for the transport ladder.
The ladder itself - which rung is tried first for a peer, and in what order the rest follow - lives in router.py (TransportRouter); the order is fips-native, iroh, libp2p, nostr and is not decided here. This module holds the pieces every rung shares: a CircuitBreaker that stops the router from hanging on a target that keeps failing, a FaultLog so that what a rung dropped and why is readable rather than only countable. The rung contract itself (RungProtocol, Rung) is in rung.py. Standard library only.
- class fleetmesh_node.transport.ladder.CircuitBreaker[source]
Bases:
objectPer-target circuit breaker to avoid hanging on repeatedly failing transports.
- record_success(target)[source]
Record successful transmission, resetting circuit to CLOSED.
- Parameters:
target (str)
- Return type:
None
- record_failure(target, now=None)[source]
Record transmission failure, potentially tripping circuit to OPEN.
- class fleetmesh_node.transport.ladder.Fault[source]
Bases:
TypedDictOne thing a rung refused or lost, kept so an operator can read it.
- class fleetmesh_node.transport.ladder.FaultLog[source]
Bases:
objectThe most recent faults of one rung and a count per family, ever.
A count alone said ‘0 faults’ while every wrap was being refused; the reasons are what tell an operator the relay said ‘ephemeral event expired’. Thread-safe; readers get copies.
4.4. Rung Base Contract
One rung of the transport ladder, and the four the node has.
The router used to know how every rung dials: four if-blocks, each with its own seal, its own breaker lookup, its own cascade note. Now a rung is one object that says whether it is up, whether it can reach a peer and where, and makes one delivery attempt; the router walks the ladder and keeps the books. A rung that is a compartment elsewhere (the relay rung, the libp2p transport) is reached through a thin adapter here so that it need not know the ladder exists.
Adapters read their daemon off the router at call time (router.fips, router.iroh, router.p2p) rather than at construction: a test swaps a fake in after the router is built, and a sidecar registers itself later.
Every rung answers the same four questions the same way - up?, where?, deliver, and what it did (health(), fault_log()) - so the router walks the ladder blindly for all of them. There is no rung the router knows by name.
- class fleetmesh_node.transport.rung.FipsRung[source]
Bases:
RungDatagram flows through the fips sidecar; mesh-encrypted by the daemon.
- class fleetmesh_node.transport.rung.IrohRung[source]
Bases:
RungEXPERIMENTAL. A direct stream the wire itself neither encrypts nor authenticates; only the JWE inside does. Built only when configured.
- class fleetmesh_node.transport.rung.Libp2pRung[source]
Bases:
RungA stream through the p2p sidecar; the target is derived from the descriptor’s transport key, so the dial is bound to what it signed.
- class fleetmesh_node.transport.rung.RelayRungAdapter[source]
Bases:
RungThe floor of the ladder: gift-wraps over the relays. Reaches every peer, so it never says no; the relay rung itself reports which relays took the wrap.
- class fleetmesh_node.transport.rung.RungHealth[source]
Bases:
TypedDictWhat a rung reports about itself; the daemon-backed rungs add their own keys.
- class fleetmesh_node.transport.rung.RungProtocol[source]
Bases:
ProtocolWhat the ladder needs from a rung, and nothing it does not.
- available()[source]
The local side of this rung is up (daemon reachable, listener bound).
- Return type:
- target_of(desc, theirs)[source]
Where this rung would reach the peer that published desc, or None when the descriptor does not advertise it. theirs is the peer’s scheme -> preference map already read from the descriptor.
- deliver(message, to_pubkey, target, anonymous)[source]
One attempt. Returns {scheme: (delivered, note)}; raises on failure so the ladder records it and moves on.
- health()[source]
What this rung reports about itself, or None when its daemon is not built; the router keys it by rung name.
- fault_log()[source]
The log of what this rung refused or lost, or None when it keeps none; the router merges every log it is given.
- Return type:
FaultLog | None
- __init__(*args, **kwargs)
4.5. Relay Rung Implementation
RelayRung: the relay rung’s state and construction. Behaviour is in the sibling mixins; this file is what an operator or a test instantiates.
- class fleetmesh_node.transport.relay_rung.core.RelayRung[source]
Bases:
OutboundMixin,ListenMixin,InboundMixin,LedgerMixin- __init__(keystore, peers, relay_urls, clock=None, timeout=15.0, seen_store=None, ack_store=None, seen_max=20000)[source]
- unfinished()[source]
Envelopes half-arrived: fragments held with pieces still missing.
A number the operator reads, so it is asked for rather than reached in for. The compartment that reports it has no business in _partials.
- Return type:
4.6. Iroh QUIC Rung
Experimental
In the code and tested, but not supported in this alpha: it may change or go away. See Experimental features.
Iroh QUIC / stream transport adapter for fleetmesh.
Protocol ALPN: fleetmesh/didcomm/1 as specified in spec.html and schema/messages.json. Provides direct, low-latency, point-to-point DIDComm streaming between mesh nodes using Iroh NodeAddr tickets and Ed25519 transport identities.
Operates in two modes: 1. Pure Python In-Process Stream Server & Client (zero external C-dependencies):
Standard-library socket streaming with 4-byte big-endian framing over ALPN fleetmesh/didcomm/1, supporting instant bi-directional request/reply and direct peer-to-peer delivery.
Iroh Sidecar Adapter Mode (iroh.sock): When an external Rust iroh daemon is running alongside the node, communicates via local UNIX domain socket to leverage full UDP hole-punching and DERP relay routing across NATs.
- fleetmesh_node.transport.iroh_rung.core.sidecar_socket_path(directory)[source]
Derive unix socket path for the iroh sidecar.
- class fleetmesh_node.transport.iroh_rung.core.IrohTransport[source]
Bases:
objectIroh QUIC / stream transport adapter.
Manages ALPN fleetmesh/didcomm/1 listeners and outbound stream dispatch.
- __init__(keystore, peers, host='127.0.0.1', port=0, ticket=None, sidecar_dir=None, clock=None, timeout=5.0, mode='stream')[source]
- property health: IrohHealthReport
Health status for operator telemetry and health check commands.
- send(message, to_pubkey, ticket=None, anonymous=False, timeout=None)[source]
Encrypt and dispatch a DIDComm envelope over an Iroh stream.
Returns { ‘iroh’: (True, ‘delivered via iroh quic stream’) }.
- request(message, to_pubkey, ticket=None, timeout=15.0, anonymous=False)[source]
Send a message and wait on the threaded response queue.
4.7. FIPS Transport Rung
Experimental
In the code and tested, but not supported in this alpha: it may change or go away. See Experimental features.
FIPS Native Datagram API Transport Client for Fleetmesh.
Spec reference: docs/fips-native-transport.md. Connects to the FIPS v0.5.1 native API socket (/var/run/fips/api.sock, ~/.fips/api.sock, …), requests FSP service flows and listener descriptors via SCM_RIGHTS, and exchanges binary-framed datagrams addressed to peer npub identities without requiring TUN/IPv6 adapters or root privileges.
- fleetmesh_node.transport.fips_rung.core.find_api_socket()[source]
Find first existing and accessible FIPS Native API socket path, or None.
- Return type:
str | None
- exception fleetmesh_node.transport.fips_rung.core.FipsTransportError[source]
Bases:
ExceptionRaised when FIPS control or flow operations fail.
- fleetmesh_node.transport.fips_rung.core.encode_frame(seq, payload, is_final=False, is_didcomm=True, compressed=False, ack_requested=False, flags=None, reserved=0)[source]
Pack payload with 8-byte binary framing header.
reservedcarries the message id used to reassemble fragmented messages.
- fleetmesh_node.transport.fips_rung.core.decode_frame_ex(data)[source]
Like decode_frame but also returns the message id: (seq, flags, msg_id, payload).
- class fleetmesh_node.transport.fips_rung.core.Reassembler[source]
Bases:
objectRebuild messages split by FipsNativeTransport.send_message on one flow.
Frames with message id 0 are legacy single-frame messages and pass through. Frames arrive in order on a FIPS flow but may be lost. A message is delivered only when fragments 0..N arrive contiguously for one message id and fragment N has FLAG_FINAL; any gap discards the partial message.
- fleetmesh_node.transport.fips_rung.core.decode_frame(data)[source]
Unpack 8-byte binary framing header.
- fleetmesh_node.transport.fips_rung.core.pubkey_to_npub(pubkey)[source]
Normalize a pubkey (hex, did:nostr:, or npub) to standard npub format.
Takes object because config and CLI hand it whatever they parsed; a non-string is stringified rather than refused, as before.
- class fleetmesh_node.transport.fips_rung.core.FipsNativeTransport[source]
Bases:
objectManages bilateral datagram flows over FIPS Native Control API.
- open_flow(peer_npub, port, timeout_s=5.0)[source]
Request connected FSP datagram flow descriptor from FIPS via SCM_RIGHTS.
- listen_port(port, timeout_s=5.0)[source]
Register inbound listener on FSP port, receiving descriptor via SCM_RIGHTS.
- accept_flow(listener_sock, timeout_s=5.0)[source]
Accept an incoming flow on a registered listener socket.
In FIPS v0.5.1, when a remote peer initiates a flow to a listening port, the listener descriptor receives an arrival notice datagram with SCM_RIGHTS carrying the new connected flow datagram socket.
- accept_listener_event(listener_sock)[source]
Receive the next incoming event on a registered listener socket.
- Returns:
(flow_sock, arrival_info, direct_msg) If an incoming flow arrived via SCM_RIGHTS: returns (flow_sock, arrival_info, b””) If a direct binary frame arrived: returns (None, {}, direct_msg) If empty/timeout: returns (None, {}, b””)
- Parameters:
listener_sock (socket)
- Return type:
- send_message(flow_sock, payload, flags=0, max_fragments=64)[source]
Send one logical message, fragmenting it to fit the flow’s max_payload.
Every frame carries the same message id in the header’s reserved byte and a per-message fragment index in
seq; the last frame sets FLAG_FINAL. Raises FipsTransportError before sending anything if the message would need more thanmax_fragmentsframes, so callers can fall back to a transport without a datagram ceiling. Returns the number of frames sent.
- send_framed(flow_sock, payload, seq=0, is_final=False, flags=None)[source]
Transmit binary-framed datagram over open flow socket.
- recv_framed(flow_sock, timeout_s=5.0)[source]
Receive and decode framed datagram. Returns (seq, is_final, payload_bytes).
4.8. mDNS Local Discovery
Enough of RFC 6762 and RFC 6763 for a node to find another on its own link.
Standard library only, like ws.py and for the same reason: this is the one discovery path that must work when there is no relay, no DNS and no internet, so it cannot be the path that needs a package index to install.
What is here is the DNS-SD subset a service advertisement uses and nothing else: PTR, SRV, TXT and A, a query for one service type, and the records that answer it. Name compression is decoded because other responders emit it, and never written, because a service advertisement is small and a pointer saves nothing worth the code.
The wire is the ordinary DNS message format on multicast. What makes it mDNS rather than DNS is where it goes - 224.0.0.251:5353, TTL 255, joined by every participant - and that an answer may arrive unsolicited, which is how a node that has just started announces itself to a link that never asked.
None of this authenticates anything and it is not supposed to. A TXT record is a routing hint: anyone on the link can claim any key. What proves a node is the descriptor fetched afterwards from the address the hint gave, which is signed. lan.py is where that happens.
- exception fleetmesh_node.transport.mdns.MdnsError[source]
Bases:
ValueError
- fleetmesh_node.transport.mdns.encode_name(name)[source]
A dotted name as length-prefixed labels, terminated by a zero byte.
- fleetmesh_node.transport.mdns.decode_name(buf, off)[source]
(name, offset after it). Follows compression pointers, and refuses a loop: a pointer must always point strictly backwards, so a packet that points forward or to itself is malformed rather than an infinite read.
- class fleetmesh_node.transport.mdns.Record[source]
Bases:
object- name
- rtype
- ttl
- data
- fleetmesh_node.transport.mdns.encode_txt(pairs)[source]
DNS-SD TXT: one length-prefixed key=value string per entry, sorted so the same map always encodes to the same bytes.
- fleetmesh_node.transport.mdns.build(questions=None, answers=None, additionals=None, flush=True)[source]
One mDNS message. A message with answers is a response (QR set); one with only questions is a query. The id is zero: mDNS matches on content, never on a transaction id, because an answer may be unsolicited.
- class fleetmesh_node.transport.mdns.Message[source]
Bases:
object- questions
- answers
- is_response
- fleetmesh_node.transport.mdns.parse(buf)[source]
A message, with every record this speaks decoded and the rest skipped.
A packet from the link is whatever anyone put on it, so every length is checked against the buffer before it is used and an unknown type is walked over by its own length rather than guessed at.
- fleetmesh_node.transport.mdns.open_socket(bind_group=True)[source]
A socket on the mDNS group, shareable with every other responder here.
SO_REUSEPORT as well as SO_REUSEADDR, because two nodes on one machine is the arrangement this project already runs - lon1 has carried two since 2026-09-04 - and without it the second one cannot bind and the pair is invisible to each other and to everyone else.
- fleetmesh_node.transport.mdns.send(sock, packet)[source]
Put one packet on the group. Raises OSError if the link refuses it.
It used to swallow that, on the grounds that no route to the group is not this node’s fault. True, and the wrong layer to decide it: a joined socket is not a link that forwards, and a host with no route for 224.0.0.0/4 or a network that filters multicast - which is what a cloud private network usually is - refuses the send itself. Swallowed here, such a node advertised nothing, said nothing about it, and reported itself as advertising. This layer says what happened; Lan._say decides what it means and puts it where an operator reads it.
- fleetmesh_node.transport.mdns.receive(sock)[source]
Every message readable right now, with the address it came from.
- fleetmesh_node.transport.mdns.local_address()[source]
This machine’s address on the interface that reaches the link.
Asked of a disconnected UDP socket, which chooses a route without sending anything: there is nothing to reach on a dead network, and this still answers because the kernel already knows which interface it would use.
- Return type:
str | None
4.9. DNS TXT Resolution
A minimal DNS TXT lookup, because the standard library has none.
The nsite gateway binds a custom domain to a site through a TXT record at _nsite.<domain>. socket can resolve A/AAAA, not TXT, and pulling in a DNS library for one record type is not worth a dependency: this is a single UDP query (RFC 1035, with the RFC 1123 TCP fallback when the answer is truncated), to the resolvers /etc/resolv.conf names, following CNAMEs in the answer section.
Returned strings are the TXT character-strings of one record joined, one entry per record, decoded as UTF-8 with errors replaced. The caller decides what a value means.
- exception fleetmesh_node.transport.dnstxt.DnsError[source]
Bases:
ExceptionThe lookup could not be completed (network, malformed answer).
4.10. DIDComm Inbound Handler
Opening an inbound DIDComm envelope: one place, every transport.
Four paths carry a JWE into this node - a gift wrap off a relay, an iroh stream, an iroh QUIC stream, and a FIPS native flow - and until this module each of them opened the envelope its own way. Three of the four were wrong in the same direction: they took the plaintext’s from as the sender’s name without anything that proved it. A frame that was never encrypted, written by anyone who could reach the socket, arrived as a message from whoever it named, and on two of the paths it arrived marked authenticated. The transport that got it right was the relay one, which is the oldest, and its rule is the rule here: the names must agree, and a name nobody proved is not a name.
What proves a sender is the ECDH-1PU agreement. didcomm.decrypt only succeeds under authcrypt if the static key skid names took part in the key agreement, so a decrypted authcrypt message was written by the holder of that key. The plaintext’s from is then required to name the same node, and on the relay path the seal’s signer too. Anoncrypt has no skid and therefore no sender: the message is delivered with authenticated=False and its from is recorded as a claim, which is what first contact is.
Anything that is not a JWE is refused. There is no plaintext path, not for discovery and not for ping: a transport that wants an unauthenticated protocol runs it beside DIDComm, not inside the queue that request() waits on. The reason strings are the ones fleetmesh_node/transport/ has always recorded, so an operator who learned to read dropped reads the same words from every rung.
Replay. A JWE is a fixed string of bytes, and a direct rung (fips flow, iroh stream, libp2p stream) carries it as-is: anyone who captured one can write it to the socket again, and the agreement proves exactly what it proved the first time - the holder of the key wrote this message, once. The relay rung has always deduplicated by wrap id; the direct rungs had nothing. So each direct rung holds an InboundGuard and hands it to open_inbound, which refuses a message id it has already opened and a created_time outside the skew window the schema tolerates. A message with no created_time is still accepted (the id check alone covers it); the gift-wrap rung passes no guard because a stored wrap is legitimately delivered days late and the wrap id is already its replay key.
- class fleetmesh_node.transport.didcomm_inbound.InboundGuard[source]
Bases:
objectPer-rung replay and freshness state: a bounded id-LRU and a clock window.
One per transport instance (never module-level: two nodes in one process must not share what they have seen). refused counts by reason so an operator can tell a replaying peer from a drifting clock.
- class fleetmesh_node.transport.didcomm_inbound.Inbound[source]
Bases:
objectOne delivered message: the plaintext, who sent it, and how it was sealed.
- fleetmesh_node.transport.didcomm_inbound.foreign(payload)[source]
Why a decrypted payload is not one of ours, in a few words.
A protocol that shares kind 21059 says whose message it is the same way DIDComm does, in a type, so that is what is named when there is one and it is the counted half of the reason. Nothing else about the payload is reported: it decrypted under this node’s key, so it may be somebody’s private traffic that merely arrived at the wrong daemon.
- fleetmesh_node.transport.didcomm_inbound.is_jwe(payload)[source]
The shape didcomm.decrypt will look at. Anything else is not tried.
- fleetmesh_node.transport.didcomm_inbound.open_inbound(payload, keystore, peers, wrap_id, seal_pk=None, guard=None, now=None)[source]
Open one inbound envelope. Returns (Inbound, None) or (None, reason).
payload: the bytes off the wire, or the object a transport already parsed (the relay path parses before it can tell a fragment from a whole). seal_pk: on the relay path, the key that signed the seal, which every other name must then equal. Transports without a seal pass None and the agreement between skid and from is what is checked. guard: a direct rung’s InboundGuard. When given, a message id already opened through it is refused as a replay, and a created_time outside the guard’s window of now (the rung’s clock; time.time() if None) is refused as stale. The relay rung passes none: its wrap id is the key.
- Exactly one of the pair is None, so a caller writes
inbound, why = open_inbound(…) if inbound is None: self._drop(why, wrap_id); return
and the reason it records is the same on every rung.
4.11. Pluggable Protocol Host
ProtocolHostRouter: Unified multiplexer for HTTP and WebSocket protocol suites.
Standard library and ws.py only. Multiplexes foreign and native protocol suites (Nostr, ATProto, ActivityPub, Blossom CAS, Prometheus metrics) over a single public edge port (e.g. 8000 or 443 with TLS).
- class fleetmesh_node.transport.host.HttpRoute[source]
Bases:
objectHttpRoute(prefix: ‘str’, handler: ‘Callable[[socket.socket, ws.PlainHTTP], Any]’, methods: ‘tuple[str, …]’, owner: ‘str’ = ‘’)
- class fleetmesh_node.transport.host.WebSocketRoute[source]
Bases:
objectWebSocketRoute(path: ‘str’, handler: ‘Callable[[ws.WebSocket, str], Any]’, owner: ‘str’ = ‘’)
- class fleetmesh_node.transport.host.ProtocolHost[source]
Bases:
objectUnified HTTP & WebSocket multiplexer mounted on the node’s public port.
- __init__(host='127.0.0.1', port=0, name='meshnode', clock=None, bind_wait=10.0, max_body_bytes=16777216)[source]
- mount_route(prefix, handler, methods=('GET',), owner='')[source]
Mount an HTTP path prefix handler.
Longest prefix matches take precedence. Handler receives (conn, req: ws.PlainHTTP) and returns True if handled, or False to fall through.
- mount_websocket(path, handler, owner='')[source]
Mount a WebSocket handler for an exact path or prefix.
- unmount_all(owner)[source]
Remove all HTTP and WebSocket routes registered by owner.
- Parameters:
owner (str)
- Return type:
None
- unregister_owner(owner)[source]
Alias for unmount_all for compatibility.
- Parameters:
owner (str)
- Return type:
None
- property server: Any | None
Underlying ws.Server instance, preserving socket address metadata even after stop.