feat(nordvpn): new API endpoint and wireguard support (#1380)

Co-authored-by: Quentin McGaw <quentin.mcgaw@gmail.com>
This commit is contained in:
Julio Gutierrez
2023-06-08 07:39:07 +00:00
committed by GitHub
parent 943943e8d1
commit 07459ee854
10 changed files with 104210 additions and 38418 deletions

View File

@@ -51,6 +51,7 @@ func (w Wireguard) validate(vpnProvider string, ipv6Supported bool) (err error)
providers.Custom,
providers.Ivpn,
providers.Mullvad,
providers.Nordvpn,
providers.Surfshark,
providers.Windscribe,
) {
@@ -140,9 +141,14 @@ func (w *Wireguard) overrideWith(other Wireguard) {
w.Implementation = gosettings.OverrideWithString(w.Implementation, other.Implementation)
}
func (w *Wireguard) setDefaults() {
func (w *Wireguard) setDefaults(vpnProvider string) {
w.PrivateKey = gosettings.DefaultPointer(w.PrivateKey, "")
w.PreSharedKey = gosettings.DefaultPointer(w.PreSharedKey, "")
if vpnProvider == providers.Nordvpn {
defaultNordVPNAddress := netip.AddrFrom4([4]byte{10, 5, 0, 2})
defaultNordVPNPrefix := netip.PrefixFrom(defaultNordVPNAddress, defaultNordVPNAddress.BitLen())
w.Addresses = gosettings.DefaultSlice(w.Addresses, []netip.Prefix{defaultNordVPNPrefix})
}
w.Interface = gosettings.DefaultString(w.Interface, "wg0")
w.MTU = gosettings.DefaultNumber(w.MTU, wireguarddevice.DefaultMTU)
w.Implementation = gosettings.DefaultString(w.Implementation, "auto")