Compiles [WIP][CI SKIP]
This commit is contained in:
@@ -13,15 +13,20 @@ pub enum ECCKey {
|
||||
|
||||
impl ECCKey {
|
||||
pub fn from_base64<I: AsRef<str>>(key: I) -> io::Result<ECCKey> {
|
||||
let key = decode(key.as_ref()).map_err(|err| {
|
||||
io::Error::new(io::ErrorKind::InvalidData, "Failed to decode base64".into())
|
||||
})?;
|
||||
let bytes = [0; 32];
|
||||
let key = match decode(key.as_ref()) {
|
||||
Ok(key) => key,
|
||||
_ => {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::InvalidData,
|
||||
"Failed to decode base64",
|
||||
))
|
||||
}
|
||||
}; /*.map_err(|err| {
|
||||
|
||||
})?;*/
|
||||
let mut bytes = [0; 32];
|
||||
if key.len() != 32 {
|
||||
return Err(io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
"Mismatched key size".into(),
|
||||
));
|
||||
return Err(io::Error::new(io::ErrorKind::Other, "Mismatched key size"));
|
||||
}
|
||||
bytes.copy_from_slice(&key);
|
||||
Ok(ECCKey::PublicKey(bytes))
|
||||
@@ -62,10 +67,11 @@ impl PeerBuilder {
|
||||
}
|
||||
|
||||
pub fn add_allowed_ip(&mut self, ip: (IpAddr, u8)) {
|
||||
if !self.allowed_ips.is_some() {
|
||||
self.allowed_ips = Some(Vec::new());
|
||||
if let Some(ref mut ips) = &mut self.allowed_ips {
|
||||
ips.push(ip);
|
||||
} else {
|
||||
self.allowed_ips = Some(vec![ip]);
|
||||
}
|
||||
self.allowed_ips.map(|ips| ips.push(ip));
|
||||
}
|
||||
|
||||
pub fn add_last_handshake(&mut self, d: Duration) {
|
||||
|
||||
Reference in New Issue
Block a user