chore(vpn): add check for empty public key for Wireguard
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
|
||||
@@ -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,
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user