Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions examples/get_wireguard_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use std::env::args;

use base64::Engine;
use base64::prelude::{Engine as _, BASE64_STANDARD};
use futures::StreamExt;
use genetlink::new_connection;
use netlink_packet_core::{
Expand Down Expand Up @@ -60,10 +60,7 @@ fn print_wg_payload(wg: WireguardMessage) {
println!("PrivateKey: (hidden)")
}
WireguardAttribute::PublicKey(v) => {
println!(
"PublicKey: {}",
base64::engine::general_purpose::STANDARD.encode(v)
)
println!("PublicKey: {}", BASE64_STANDARD.encode(v))
}
WireguardAttribute::ListenPort(v) => println!("ListenPort: {}", v),
WireguardAttribute::Fwmark(v) => println!("Fwmark: {}", v),
Expand All @@ -82,10 +79,7 @@ fn print_wg_peer(attrs: &[WireguardPeerAttribute]) {
for attr in attrs {
match attr {
WireguardPeerAttribute::PublicKey(v) => {
println!(
" PublicKey: {}",
base64::engine::general_purpose::STANDARD.encode(v)
)
println!(" PublicKey: {}", BASE64_STANDARD.encode(v))
}
WireguardPeerAttribute::PresharedKey(_) => {
println!(" PresharedKey: (hidden)")
Expand Down
13 changes: 6 additions & 7 deletions examples/set_wireguard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::{
net::{IpAddr, Ipv4Addr, SocketAddr},
};

use base64::Engine;
use base64::prelude::{Engine as _, BASE64_STANDARD};
use futures::StreamExt;
use genetlink::new_connection;
use netlink_packet_core::{
Expand All @@ -33,12 +33,11 @@ async fn main() {
// This can be done with `ip link <name> type wireguard` command.
let name = argv[1].clone();
let priv_key = generate_priv_key();
let peer_pub_key: [u8; WireguardAttribute::WG_KEY_LEN] =
base64::engine::general_purpose::STANDARD
.decode("8bdQrVLqiw3ZoHCucNh1YfH0iCWuyStniRr8t7H24Fk=")
.unwrap()
.try_into()
.unwrap();
let peer_pub_key: [u8; WireguardAttribute::WG_KEY_LEN] = BASE64_STANDARD
.decode("8bdQrVLqiw3ZoHCucNh1YfH0iCWuyStniRr8t7H24Fk=")
.unwrap()
.try_into()
.unwrap();

let (connection, mut handle, _) = new_connection().unwrap();
tokio::spawn(connection);
Expand Down
Loading