cloudflare / boringtun

Userspace WireGuard® Implementation in Rust
BSD 3-Clause "New" or "Revised" License
6.12k stars 415 forks source link

Set configuration file #318

Open max-frai opened 2 years ago

max-frai commented 2 years ago

Hello, is it possible with boringtun core library to set configuration? My main goal is just to use vpn connection file and setup vpn connection in system with this library. So I have config file with keys, servers from my vpn provider. It looks like:

[Interface]
# NetShield = 0
# Moderate NAT = off
# VPN Accelerator = on
PrivateKey = PRIVATE KEY HERE
Address = SERVER ADDRESS/32
DNS = SERVER ADDRESS

[Peer]
PublicKey = PUBLIC KEY HERE
AllowedIPs = 0.0.0.0/0
Endpoint = SERVER ADDRESS:51820

How can I "apply" it to created tunnel? So I did the same logic as cli and check with wg show:

interface: utun42
  listening port: 58873

With wg-quick I can put config file into /etc/wireguard/test.conf and run it: wg-quick up test. And it creates vpn connection and works okay. Can I do the same with only this library? Or I should apply this config file on created tunnel with some other tool?

Noah-Kennedy commented 2 years ago

If you are trying to do this with just the library, you will need to parse the file and instantiate the various objects yourself with the configuration parameters from the parsed file.