Wireguard support for Mullvad and Windscribe (#565)
- `internal/wireguard` client package with unit tests - Implementation works with kernel space or user space if unavailable - `WIREGUARD_PRIVATE_KEY` - `WIREGUARD_ADDRESS` - `WIREGUARD_PRESHARED_KEY` - `WIREGUARD_PORT` - `internal/netlink` package used by `internal/wireguard`
This commit is contained in:
25
internal/wireguard/address.go
Normal file
25
internal/wireguard/address.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package wireguard
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net"
|
||||
|
||||
"github.com/vishvananda/netlink"
|
||||
)
|
||||
|
||||
func (w *Wireguard) addAddresses(link netlink.Link,
|
||||
addresses []*net.IPNet) (err error) {
|
||||
for _, ipNet := range addresses {
|
||||
address := &netlink.Addr{
|
||||
IPNet: ipNet,
|
||||
}
|
||||
|
||||
err = w.netlink.AddrAdd(link, address)
|
||||
if err != nil {
|
||||
return fmt.Errorf("%w: when adding address %s to link %s",
|
||||
err, address, link.Attrs().Name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
Reference in New Issue
Block a user