mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-04-22 23:16:55 +02:00
cleanup
This commit is contained in:
parent
dc8fa144ad
commit
181eb8ac34
7 changed files with 20 additions and 13 deletions
|
@ -102,12 +102,12 @@ where
|
|||
|
||||
impl<T> Valid<T> {
|
||||
#[inline(always)]
|
||||
pub fn unwrap(self) -> T {
|
||||
pub fn remove_typestate(self) -> T {
|
||||
self.0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn wrap(o: T) -> Self {
|
||||
pub fn mark_valid(o: T) -> Self {
|
||||
Self(o)
|
||||
}
|
||||
}
|
||||
|
@ -212,12 +212,12 @@ where
|
|||
|
||||
impl<T> Verified<T> {
|
||||
#[inline(always)]
|
||||
pub fn unwrap(self) -> T {
|
||||
pub fn remove_typestate(self) -> T {
|
||||
self.0
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn wrap(o: T) -> Self {
|
||||
pub fn mark_verified(o: T) -> Self {
|
||||
Self(o)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -206,7 +206,7 @@ impl Identity {
|
|||
assert!(id.upgrade().is_ok());
|
||||
assert!(id.p384.is_some() && id.secret.as_ref().unwrap().p384.is_some());
|
||||
|
||||
Valid::wrap(id)
|
||||
Valid::mark_valid(id)
|
||||
}
|
||||
|
||||
/// Upgrade older x25519-only identities to hybrid identities with both x25519 and NIST P-384 curves.
|
||||
|
@ -321,7 +321,7 @@ impl Identity {
|
|||
zt_address_derivation_work_function(&mut digest);
|
||||
|
||||
return if digest[0] < IDENTITY_POW_THRESHOLD && Address::from_bytes(&digest[59..64]).map_or(false, |a| a == self.address) {
|
||||
Some(Valid::wrap(self))
|
||||
Some(Valid::mark_valid(self))
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
|
|
@ -298,7 +298,7 @@ impl Node {
|
|||
let old = id.clone();
|
||||
if id.upgrade()? {
|
||||
app.save_node_identity(&id);
|
||||
app.event(Event::IdentityAutoUpgraded(old.unwrap(), id.as_ref().clone()));
|
||||
app.event(Event::IdentityAutoUpgraded(old.remove_typestate(), id.as_ref().clone()));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,14 @@ impl Node {
|
|||
/// Get the root sets that this node trusts.
|
||||
#[inline]
|
||||
pub fn root_sets(&self) -> Vec<RootSet> {
|
||||
self.roots.read().unwrap().sets.values().cloned().map(|s| s.unwrap()).collect()
|
||||
self.roots
|
||||
.read()
|
||||
.unwrap()
|
||||
.sets
|
||||
.values()
|
||||
.cloned()
|
||||
.map(|s| s.remove_typestate())
|
||||
.collect()
|
||||
}
|
||||
|
||||
pub fn do_background_tasks<Application: ApplicationLayer + ?Sized>(&self, app: &Application) -> Duration {
|
||||
|
@ -468,7 +475,7 @@ impl Node {
|
|||
if let Some(peer) = peers.get(&m.identity.address) {
|
||||
new_roots.insert(peer.clone(), m.endpoints.as_ref().unwrap().iter().cloned().collect());
|
||||
} else {
|
||||
if let Some(peer) = Peer::new(&self.identity, Valid::wrap(m.identity.clone()), time_ticks) {
|
||||
if let Some(peer) = Peer::new(&self.identity, Valid::mark_valid(m.identity.clone()), time_ticks) {
|
||||
drop(peers);
|
||||
new_roots.insert(
|
||||
self.peers
|
||||
|
|
|
@ -119,7 +119,7 @@ impl RootSet {
|
|||
}
|
||||
}
|
||||
|
||||
return Some(Verified::wrap(self));
|
||||
return Some(Verified::mark_verified(self));
|
||||
}
|
||||
|
||||
/// Add a member to this definition, replacing any current entry with this address.
|
||||
|
|
|
@ -177,7 +177,7 @@ impl CertificateOfMembership {
|
|||
&self.issued_to_fingerprint.as_bytes()[..32],
|
||||
) {
|
||||
if issuer.verify(&self.v1_proto_get_qualifier_bytes(), self.signature.as_bytes()) {
|
||||
return Some(Verified::wrap(self));
|
||||
return Some(Verified::mark_verified(self));
|
||||
}
|
||||
}
|
||||
return None;
|
||||
|
|
|
@ -45,7 +45,7 @@ pub fn parse_cli_identity(input: &str, validate: bool) -> Result<Identity, Strin
|
|||
if !validate {
|
||||
Ok(id)
|
||||
} else if let Some(id) = id.validate() {
|
||||
Ok(id.unwrap())
|
||||
Ok(id.remove_typestate())
|
||||
} else {
|
||||
Err(String::from("invalid identity: local validation failed"))
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ pub fn load_node_identity(base_path: &Path) -> Option<Valid<Identity>> {
|
|||
if id_data.is_err() {
|
||||
return None;
|
||||
}
|
||||
Some(Valid::wrap(id_data.unwrap()))
|
||||
Some(Valid::mark_valid(id_data.unwrap()))
|
||||
}
|
||||
|
||||
pub fn save_node_identity(base_path: &Path, id: &Valid<Identity>) -> bool {
|
||||
|
|
Loading…
Add table
Reference in a new issue