Skip to content

Provide Example for presharedkey implementation #41

Open
@Ange-Cesari

Description

@Ange-Cesari

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 :

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 ?

let presharedkeysecret = EphemeralSecret::random();
peer.presharedkey.push(presharedkeysecret);

Thanks,
Ange

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions