pub struct Hello {
pub proto_min: u32,
pub proto_max: u32,
pub card: RuntimeCard,
pub nonce: String,
pub ts: u64,
pub to: Option<String>,
}Expand description
A dialer’s hello: everything the answerer needs to decide whether to link, in one signed message. The nonce makes the exchange unrepeatable — the welcome must echo it, and a nonce is never accepted twice — and the timestamp makes it unstorable, since a hello captured today cannot be presented tomorrow. The protocol range is stated rather than assumed, so two executables of different ages find their common version here and nowhere else.
use majordomus_cli::mesh::identity::NodeIdentity;
use majordomus_cli::mesh::link::{fresh_token, sign, verify_signed, Domain, Hello,
RuntimeCard, LINK_PROTOCOL_MAX, LINK_PROTOCOL_MIN};
let node = NodeIdentity::ephemeral().unwrap();
let hello = Hello {
proto_min: LINK_PROTOCOL_MIN,
proto_max: LINK_PROTOCOL_MAX,
card: RuntimeCard {
pk: node.public.public_key.clone(),
runtime: "00000000000000aa".into(),
instance: node.public.instance_id.as_str().into(),
repo: "r".repeat(32),
name: String::new(),
version: String::new(),
features: vec![],
endpoints: vec![],
},
nonce: fresh_token(),
ts: 1_700_000_000,
to: None,
};
assert_eq!(hello.nonce.len(), 32, "32 hex of fresh entropy, echoed by the welcome");
let signed = sign(&node, Domain::Hello, serde_json::to_value(&hello).unwrap());
assert!(verify_signed(&node.public.public_key, Domain::Hello, &signed));Fields§
§proto_min: u32The oldest link protocol the dialer speaks.
proto_max: u32The newest link protocol the dialer speaks.
card: RuntimeCardThe dialer.
nonce: String32 hex of fresh entropy: the welcome must echo it, and it is never accepted twice.
ts: u64The dialer’s clock, seconds since the Unix epoch.
to: Option<String>The runtime key of the runtime this hello is addressed to, when the dialer knows it:
inside the signed bytes, so a hello captured on its way to one runtime is refused as
misaddressed by every other. Absent from a dialer that does not know whom it dials
(a seed, a first contact) and from releases before it existed; such a hello is still
accepted, and only an addressed one carries the protection.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Hello
impl<'de> Deserialize<'de> for Hello
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for Hello
Source§impl JsonSchema for Hello
impl JsonSchema for Hello
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read moreimpl StructuralPartialEq for Hello
Auto Trait Implementations§
impl Freeze for Hello
impl RefUnwindSafe for Hello
impl Send for Hello
impl Sync for Hello
impl Unpin for Hello
impl UnsafeUnpin for Hello
impl UnwindSafe for Hello
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.