Draft: Simplify BridgeLine struct and make it variable length
Closes #60
This is a big change, all for the purpose of removing the fixed length limit from the BridgeLine struct. While I was making the change, I took the liberty of modifying the BridgeLine into something more usable for the client.
Note: this change is not backwards compatible, but it was never going to be. Even if all we changed was the BRIDGE_BYTES value, old clients wouldn't be able to decrypt/decode the bridge table entries properly because they assumed an outdated value. However, this change should provide a path towards backwards compatibility if changes are made later.
To break down the changes into pieces:
-
The new
BridgeLinestruct was modified to:pub struct BridgeLine { pub uid_fingerprint: u64, pub line: String, }We didn't need the other fields for anything Lox related, and all the client really needs is the bridge line string. Note also that there is no fixed length for the
linefield. -
Modified the encoding of
BucketandBridgeLineto use protobufsThe previous encoding relied on both structs having fixed-length fields. I went with protobufs for a few reasons:
- There is a nice library for it, called prost, that is popular and maintained by the tokio-rs project.
- It's interoperable, meaning that we're using a deterministic protobuf schema, so any other client implementation that uses the same schema should be able to decode and decrypt the bridge table entries just fine.
- It allows for forward and backward compatibility, though we have to be careful here. The prost library allows us to annotate struct fields with tags, which help maintain a deterministic schema even if we reorder or remove struct fields. We have to be careful though if we rename the fields or add new ones, to use a different tag for it.
-
The
Resourcestruct in the rdsys-backend-api crate changed the type of theparamsfield:pub struct Resource { pub r#type: String, pub blocked_in: HashMap<String, bool>, pub test_result: TestResults, pub protocol: String, pub address: String, pub port: u16, pub fingerprint: String, #[serde(rename = "or-addresses")] pub or_addresses: Option<Vec<String>>, pub distribution: String, pub flags: Option<HashMap<String, bool>>, #[serde_as(as = "Option<Map<_,_>>")] pub params: Option<Vec<(String, String)>>, }This change was necessary to create a deterministic bridge line string when parsing the resources in the lox-distributor.
-
Lots of new new tests