DefGuard / DefGuard/wireguard-rs

Provide Example for presharedkey implementation

Open
#41 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
330
Forks
34
Avg merge
1d 12h
Merged PRs (30d)
4

Description

Hi,

The issue with the presharedkey seems to have been fixed (#11). Currently, there is no example (server, userspace or client) to provide a presharedkey.

In the following snippet of code from `server.rs` file you created 10 peers, you sat them up and you configured them :

```rust
for peer_id in 3..13 {
let secret = EphemeralSecret::random();
let key = PublicKey::from(&secret);
let peer_key: Key = key.as_ref().try_into().unwrap();
peer_keys.push(peer_key.clone());
let mut peer = Peer::new(peer_key)
let addr = IpAddrMask::from_str(&format!("10.20.30.{peer_id}/32")).unwrap();
peer.allowed_ips.push(addr);
wgapi.configure_peer(&peer)?;
}
```

Would it be possible to have an example on how to create the presharedkey from your library and set it to a peer?

I didn't see any setter for the presharedkey in the Peer implementation. Is it somewhere else ?

would something like this be sufficient ?
```rust
let presharedkeysecret = EphemeralSecret::random();
peer.presharedkey.push(presharedkeysecret);
```

Thanks,
Ange

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.