diff options
| author | eunhhu <[email protected]> | 2026-09-28 19:16:39 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-28 19:16:39 +0100 |
| commit | 09b754f2490dec5582ba79c9cde55b32bac12bcf (patch) | |
| tree | 51f93709b1375648a5f2e61d625d908c0a676085 /serve/link.h | |
| parent | ec210a8aed62c301e9ae384d4d157e379fa58f54 (diff) | |
| download | pure-09b754f2490dec5582ba79c9cde55b32bac12bcf.tar.gz pure-09b754f2490dec5582ba79c9cde55b32bac12bcf.zip | |
Let a link at rest cost the listener only its allowing
A sender allowed is now a peer of 48 bytes (its key, its key's id, its
sources), found through an index by key id; ids are 32 bits, so keys that
share one are each tried. What a sending peer needs besides (the secret
its key shares with the node's, its runs' keys and addresses, its
streams) is made at its first packet and let go once it has been quiet
for the idle period (--link-idle-ms, 30 s at first) with nothing of it
waiting: the next packet makes it again, one X25519, no handshake. The
listener hands over and answers only the streams and runs that changed,
not every one at each turn. --senders FILE allows senders a line each.
The UDP link checks take their sender from such a file among a thousand
others, let it go after 400 ms of quiet, and see an order after a longer
pause arrive all the same.
Diffstat (limited to 'serve/link.h')
| -rw-r--r-- | serve/link.h | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/serve/link.h b/serve/link.h index bbda882..51f12bd 100644 --- a/serve/link.h +++ b/serve/link.h @@ -14,7 +14,8 @@ * A packet is a header in the clear, then frames sealed with AES-128-GCM * (the header as associated data): * u8 0x70 (version 0), u32le the key id of the node that sent it (FNV-1a - * of its public key), u64le that node's run (random, new each time it + * of its public key; two keys may share an id, and a receiver tries the + * keys it allows with it), u64le that node's run (random, new each time it * starts, so no nonce repeats under a key across restarts), u64le the * packet's number in its run. * Keys come from the secret the two nodes' keys share (X25519) by @@ -61,7 +62,8 @@ bool pure_link_start(PureLink *, void (*notify)(void *), void *context, char *er void pure_link_close(PureLink *); /* The receiving side: packets on a UDP port, from the senders allowed (a - * source name and the key it seals with). Whole records of a stream, in + * source name and the key it seals with, a few bytes each however many + * there are: see pure_link_idle). Whole records of a stream, in * order, go to deliver (on the listener's thread) as one delivery; the host * applies them from the one after the source's last heard number, stops at * a gap, saves, and then calls pure_link_done (any thread) with the last @@ -83,15 +85,21 @@ PureLinkListener *pure_link_listen(const PureModule *m, unsigned port, const Pur size_t size); bool pure_link_allow(PureLinkListener *, const char *source, const unsigned char key[PURE_SEAL_KEY], char *error, size_t size); +/* A sender quiet for ms (30 s at first) with nothing of it waiting lets its + * keys, addresses and streams go: an idle link costs the listener only its + * allowing, and the sender's next packet makes them again (one X25519). */ +void pure_link_idle(PureLinkListener *, uint64_t ms); bool pure_link_serve(PureLinkListener *, char *error, size_t size); /* stored: the delivery's save succeeded; gap: it stopped at a gap. */ void pure_link_done(PureLinkListener *, void *token, uint64_t heard, bool stored, bool gap); /* Counts for a host's report: packets and records sent, records sent again, * packets lost and acknowledged, packets received, deliveries handed over, - * the last number stored. A listener's are given when it closes. */ + * the last number stored; a listener's senders woken (their active state + * made), let go when idle, and active when it closed. A listener's are + * given when it closes. */ typedef struct { - uint64_t packets, records, resent, lost, acknowledged, received, deliveries, stored; + uint64_t packets, records, resent, lost, acknowledged, received, deliveries, stored, woken, swept, active; } PureLinkCounts; void pure_link_counts(PureLink *, PureLinkCounts *); void pure_link_listener_close(PureLinkListener *, PureLinkCounts *counts); |
