Implement Debug for WgKey
When we derive debug we get an unreadable bytes dump any time we debug
print a struct containing a WgKey. This change will allow us to read
these addresses as normal strings rather than having to hand decode a
byte array to figure out what router is being referenced.
@@ -8,7 +8,7 @@ use sodiumoxide::crypto::box_::curve25519xsalsa20poly1305::SecretKey;
use std::fmt;
use std::str::FromStr;
-#[derive(Hash, Debug, Copy, Clone, Eq, PartialEq)]
+#[derive(Hash, Copy, Clone, Eq, PartialEq)]
pub struct WgKey([u8; 32]);
impl AsRef<[u8]> for WgKey {
@@ -50,6 +50,12 @@ impl fmt::Display for WgKey {
}
}
+impl fmt::Debug for WgKey {
+ fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
+ write!(f, "{}", base64::encode(&self))
+ }
+}
+
impl FromStr for WgKey {
type Err = AltheaTypesError;
