Compiles [WIP][CI SKIP]

This commit is contained in:
Drone CI
2019-03-20 16:12:24 +01:00
parent fac5c7c442
commit 9993a8f7a4
2 changed files with 55 additions and 30 deletions

View File

@@ -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) {