use base64 ids
This commit is contained in:
parent
da029637a1
commit
e432793aeb
@ -1,9 +1,13 @@
|
||||
FROM rust:1.31.1 AS eventbuild
|
||||
|
||||
COPY wg-event-gen/ /build
|
||||
|
||||
WORKDIR /build
|
||||
|
||||
COPY wg-event-gen/Cargo.* /build/
|
||||
|
||||
RUN mkdir -p src && echo "fn main() {}" > src/main.rs && cargo build --release
|
||||
|
||||
COPY wg-event-gen/ /build
|
||||
|
||||
RUN cargo build --release
|
||||
|
||||
FROM golang AS build
|
||||
|
24
wg-event-gen/Cargo.lock
generated
24
wg-event-gen/Cargo.lock
generated
@ -1,14 +1,30 @@
|
||||
[[package]]
|
||||
name = "strum"
|
||||
version = "0.13.0"
|
||||
name = "base64"
|
||||
version = "0.10.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
dependencies = [
|
||||
"byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.2.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "hex"
|
||||
version = "0.3.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
|
||||
[[package]]
|
||||
name = "wg-event-gen"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"strum 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
"hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||
]
|
||||
|
||||
[metadata]
|
||||
"checksum strum 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f6b3fc98c482ff9bb37a6db6a6491218c4c82bec368bd5682033e5b96b969143"
|
||||
"checksum base64 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "621fc7ecb8008f86d7fb9b95356cd692ce9514b80a86d85b397f32a22da7b9e2"
|
||||
"checksum byteorder 1.2.7 (registry+https://github.com/rust-lang/crates.io-index)" = "94f88df23a25417badc922ab0f5716cc1330e87f71ddd9203b3a3ccd9cedf75d"
|
||||
"checksum hex 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)" = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77"
|
||||
|
@ -5,4 +5,5 @@ authors = ["shimun <wg.shimun@shimun.net>"]
|
||||
edition = "2018"
|
||||
|
||||
[dependencies]
|
||||
strum = "0.13.0"
|
||||
hex = "0.3.2"
|
||||
base64 = "0.10.0"
|
||||
|
@ -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()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user