use base64 ids

This commit is contained in:
shim_
2019-01-13 15:31:03 +01:00
parent da029637a1
commit e432793aeb
4 changed files with 33 additions and 10 deletions

View File

@@ -5,6 +5,8 @@ use crate::gen::*;
use crate::listener::*;
use std::collections::HashMap;
use hex;
use base64;
use std::env;
use std::fmt;
use std::io::prelude::*;
@@ -42,7 +44,7 @@ impl Peer {
None => return Err(Error::new(ErrorKind::Other, "Peer is missing key")),
};
Ok(Peer {
public_key: key.to_string(),
public_key: base64::encode(&hex::decode(key).unwrap()),
endpoint: entries
.iter()
.filter(|(key, _)| key == &"endpoint")
@@ -77,11 +79,11 @@ impl State {
}
}
pub fn id<'a>(&'a self) -> Option<&'a String> {
pub fn id<'a>(&'a self) -> Option<String> {
self.kv()
.iter()
.filter(|(key, _)| key == &"private_key" || key == &"public_key")
.map(|(_, value)| value)
.map(|(_, value)| base64::encode(&hex::decode(&value).unwrap()))
.next()
}