magpipe 0.3.0
magpipe: ^0.3.0 copied to clipboard
Magpie Bridge pipe transport: shared-socket UDP connections (hub), packet framing for bridge/direct links, and the enigma secret box (HKDF-SHA256 + AES-256-GCM).
magpipe #
Magpie Bridge pipe transport for Dart: one shared UDP socket, many connections.
- MagHub: binds the shared socket once and multiplexes every connection registered on it (inbound datagrams are routed by remote endpoint), with a run loop that heartbeats idle links and re-connects dead ones (docs/client.md §6, §8).
- BridgeLink / DirectLink: connection to the relay server (B=1, with the SYN?/SYN!/ACK! handshake, heartbeat and enigma) or directly to a peer (B=0, stateless).
- Packet framing: bridge/direct packet classes and factories
(SYN?/SYN!/ACK!, FAIL/DONE, ACPT/DENY, PING/PONG, FIN?/FIN!, NOOP,
DATA/COPY), including signed
ReliablePacket(HMAC-SHA256). - Enigma: decrypts the handshake secret with HKDF-SHA256 +
AES-256-GCM (
HkdfEnc/HkdfSha256).
See docs/protocol.md in the Magpie Bridge repository for the wire
format and docs/client.md for the client behaviour.
Usage #
var hub = await MagHub.create();
// bridge connection to the relay server (B=1):
var bridge = hub.connectBridge(server);
var bridgePipe = hub.getBridgePipe(server, targetBid);
// direct connection to a peer (B=0):
var direct = hub.connect(peer);
var directPipe = hub.getDirectPipe(peer);
...
hub.disconnect(server);
License #
MIT — see LICENSE.