Skip to content

Commit

Permalink
chore(vpn): add check for empty public key for Wireguard
Browse files Browse the repository at this point in the history
  • Loading branch information
qdm12 committed Jun 12, 2022
1 parent d4c6a9b commit fb62de8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions internal/provider/utils/connection.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package utils

import (
"errors"
"fmt"
"math/rand"

Expand Down Expand Up @@ -29,6 +30,10 @@ type Storage interface {
servers []models.Server, err error)
}

var (
ErrWireguardPublicKeyMissing = errors.New("wireguard public key is missing")
)

func GetConnection(provider string,
storage Storage,
selection settings.ServerSelection,
Expand All @@ -52,6 +57,11 @@ func GetConnection(provider string,
continue
}

if selection.VPN == vpn.Wireguard && server.WgPubKey == "" {
return connection, fmt.Errorf("%w: for server hostname %s and ip %s",
ErrWireguardPublicKeyMissing, server.Hostname, ip)
}

hostname := server.Hostname
if selection.VPN == vpn.OpenVPN && server.OvpnX509 != "" {
// For Windscribe where hostname and
Expand Down

0 comments on commit fb62de8

Please sign in to comment.