[−][src]Crate cjdns_ann
Library for parsing cjdns route announcement messages.
Each cjdns announcement message contains message header, a sequence of entities and some additional data derived from header. For example, senders auth curve25519 encryption key is derived from the announcement header.
Header
The header is 120 bytes long and contains an ed25519 signature over the entire announcement,
the public signing key (which is used to create senders auth encryption key using ed25519 -> curve25519
conversion) of the node which created the announcement, the cjdns IPv6 address of the supernode to which this subnode is announcing,
a timestamp, version and a reset flag. On the 03.09.2020 announcement protocol version is 1
.
Announcement header packet diagram looks as follows:
1 2 3
0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7 0 1 2 3 4 5 6 7
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
0 | |
+ +
4 | |
+ +
8 | |
+ +
12 | |
+ +
16 | |
+ +
20 | |
+ +
24 | |
+ +
28 | |
+ Signature +
32 | |
+ +
36 | |
+ +
40 | |
+ +
44 | |
+ +
48 | |
+ +
52 | |
+ +
56 | |
+ +
60 | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
64 | |
+ +
68 | |
+ +
72 | |
+ +
76 | |
+ Public Signing Key +
80 | |
+ +
84 | |
+ +
88 | |
+ +
92 | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
96 | |
+ +
100 | |
+ SuperNode IP +
104 | |
+ +
108 | |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
112 | |
+ Timestamp +-+-+-+-+
116 | |R| ver |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Entities
Every entity in announcement message begins with two bytes, indicating length and type, at the time of this writing the types of entities are:
EncodingScheme
with type number0
. The entity contains serialized representation of encoding scheme created by serializer. Please look here for more information about how this is parsed.Peer
with type number1
. EachPeer
entity contains roughly the information which is needed to reach the announcer from a given peer. It is important to note that this is not about ability to reach the peer, but to reach the announcer if one can already reach said peer.NodeProtocolVersion
with type number2
. The entity tells the protocol version of the node sending it.LinkState
with type number3
.
Entity messages all begin with the length of the entity such that future entities can be added and skipped over by older versions of the parser. Entities longer than 255 or shorter than 1 byte are invalid. If the entity length field is exactly 1 byte, it is a pad and that byte should be skipped over. Pads can be useful to byte-align messages with oddly sized entities.
Example
use cjdns_ann::AnnouncementPacket; // creating packet let announcement_packet = AnnouncementPacket::try_new(announcement_bytes).unwrap(); // checking announcement signature assert!(announcement_packet.check().is_ok()); // parsing announcement packet let deserialized_announcement = announcement_packet.parse().unwrap();
Structs
AnnHash | 512-bit hash |
Announcement | Deserialized cjdns route announcement message. |
AnnouncementHeader | Deserialized announcement message header. |
AnnouncementPacket | Serialized announcement message. A thin wrapper over announcement packet bytes. |
LinkStateData | |
PeerData |
Enums
Entity | Announcement message entity types. |
Constants
LINK_STATE_SLOTS | Samples are collected every 10 seconds, normally messages are submitted to the Route Server every minute, resulting in 6 samples. But we would store 3 times more samples so that if there is some reason it is unable to submit a message to the route server for up to 3 minutes, still no link state samples will be lost. |
Type Definitions
AnnouncementEntities | A sequence of entities in the announcement message. |
LinkStateSlots | An array of slots storing network link samples. |