Comments (1)
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)
- Add Windows support for defguard client HOT 4
- Wireguard-rs on crates.io HOT 1
- Presharedkey support HOT 8
- How work write and delete peer ? HOT 3
- Can clone trait cause damage to host and WGApi ? HOT 3
- OS Error 19 with defguard_wireguard_rs 0.2.0 from crates.io for the server example HOT 1
- Unable to change existing WireGuard interface address on Linux HOT 1
- Sequence of creating peers and host blurry HOT 3
- Mutiple allowed ips not working in peer (wg show) HOT 1
- Enrich example with how to use preshared key inside the server.rs
- Route adding when creating the interface not working
- Mandatory steps for configuring the peer ?
- Clone trait for the WGApi ? HOT 1
- Release wireguard-rs 0.3
- After disconnecting DNS rules are not removed
- Release wireguard_rs 0.3.1
- Update README Wireguard-RS with Windows
- Remove sensitive info from debug logs on Windows
- Add option to set MTU
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wireguard-rs.