Skip to main content

magpipe 0.3.1 copy "magpipe: ^0.3.1" to clipboard
magpipe: ^0.3.1 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 #

License PRs Welcome Platform Issues Repo Size Tags Version

Watchers Forks Stars Followers

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).
  • Receiving: the default processPacket answers "COPY" to data packets and "PONG" to heartbeats; override it on your pipe subclass to plug in your own dedup, fragment reassembly and delivery.

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);

// send data through a pipe (sn/index/count for the reliability layer):
directPipe.sendData(payload, sn: 1);

// or send a pre-built packet (routed by its B flag):
hub.sendPacket(packet, remote: server);

...
hub.disconnect(server);

License #

MIT — see LICENSE.

0
likes
0
points
773
downloads

Publisher

unverified uploader

Weekly Downloads

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).

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

magpie_bridge, pointycastle

More

Packages that depend on magpipe