Git Product home page Git Product logo

Comments (1)

Ange-Cesari avatar Ange-Cesari commented on May 23, 2024

Hi,

Here is a little insights for people that want to know how to implement it :

You can insert your preshared key inside the peer using the insert method.

Let's take the example again. In the for loop, we first create the secret then we create the Publickey from the secret, push the peer key in the vec named peer_keys, then create a peer from the public key, create an address according to the peer id and then push in the allowed_ips field of the structure peer, then configure the peer to be written on the API.

This workflow does not include the preshared_keys yet. To do so, you must bear in mind that the preshared_keys are a type Key (same type as the key used to create the peer)

To create the key simply do :

let peer_psk_secret = StaticSecret::random();
let peer_u8_psk: [u8; 32] = peer_psk_secret.to_bytes().as_ref().try_into().expect(could not convert static secret to u8)
let peer_psk_key: Key = peer_psk_secret.as_ref().try_into().expect("could not convert key u8 to key")
peer.preshared_keys.insert(peer_psk_key)

There might be unecessary steps for conversions but It works well for me.
Maybe @teon or @wojcik91 can add a sample of this to the server.rs example

from wireguard-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.