Remove support for multihop
This commit is contained in:
@@ -24,13 +24,11 @@ type apiDataCenter struct {
|
||||
}
|
||||
|
||||
type apiServer struct {
|
||||
IP netip.Addr `json:"ip"`
|
||||
Ptr string `json:"ptr"` // hostname
|
||||
Online bool `json:"online"`
|
||||
PublicKey string `json:"public_key"`
|
||||
WireguardPorts []uint16 `json:"wireguard_ports"`
|
||||
MultiHopOpenvpnPort uint16 `json:"multihop_openvpn_port"`
|
||||
MultiHopWireguardPort uint16 `json:"multihop_wireguard_port"`
|
||||
IP netip.Addr `json:"ip"`
|
||||
Ptr string `json:"ptr"` // hostname
|
||||
Online bool `json:"online"`
|
||||
PublicKey string `json:"public_key"`
|
||||
WireguardPorts []uint16 `json:"wireguard_ports"`
|
||||
}
|
||||
|
||||
func fetchAPI(ctx context.Context, client *http.Client) (
|
||||
@@ -109,13 +107,11 @@ func (a *apiDataCenter) validate() (err error) {
|
||||
}
|
||||
|
||||
var (
|
||||
ErrIPFieldNotValid = errors.New("ip address is not set")
|
||||
ErrHostnameFieldNotSet = errors.New("hostname field is not set")
|
||||
ErrPublicKeyFieldNotSet = errors.New("public key field is not set")
|
||||
ErrWireguardPortsNotSet = errors.New("wireguard ports array is not set")
|
||||
ErrWireguardPortNotDefault = errors.New("wireguard port is not the default 9929")
|
||||
ErrMultiHopOpenVPNPortNotSet = errors.New("multihop OpenVPN port is not set")
|
||||
ErrMultiHopWireguardPortNotSet = errors.New("multihop WireGuard port is not set")
|
||||
ErrIPFieldNotValid = errors.New("ip address is not set")
|
||||
ErrHostnameFieldNotSet = errors.New("hostname field is not set")
|
||||
ErrPublicKeyFieldNotSet = errors.New("public key field is not set")
|
||||
ErrWireguardPortsNotSet = errors.New("wireguard ports array is not set")
|
||||
ErrWireguardPortNotDefault = errors.New("wireguard port is not the default 9929")
|
||||
)
|
||||
|
||||
func (a *apiServer) validate() (err error) {
|
||||
@@ -129,8 +125,6 @@ func (a *apiServer) validate() (err error) {
|
||||
err: ErrWireguardPortNotDefault,
|
||||
condition: len(a.WireguardPorts) != 1 || a.WireguardPorts[0] != defaultWireguardPort,
|
||||
},
|
||||
{err: ErrMultiHopOpenVPNPortNotSet, condition: a.MultiHopOpenvpnPort == 0},
|
||||
{err: ErrMultiHopWireguardPortNotSet, condition: a.MultiHopWireguardPort == 0},
|
||||
}
|
||||
err = collectErrors(conditionalErrors)
|
||||
switch {
|
||||
|
||||
@@ -72,13 +72,11 @@ func Test_fetchAPI(t *testing.T) {
|
||||
DataCenters: []apiDataCenter{
|
||||
{CountryName: "Austria", City: "Vienna", Servers: []apiServer{
|
||||
{
|
||||
IP: netip.MustParseAddr("37.120.212.227"),
|
||||
Ptr: "vpn44.prd.vienna.ovpn.com",
|
||||
Online: true,
|
||||
PublicKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||
WireguardPorts: []uint16{9929},
|
||||
MultiHopOpenvpnPort: 20044,
|
||||
MultiHopWireguardPort: 30044,
|
||||
IP: netip.MustParseAddr("37.120.212.227"),
|
||||
Ptr: "vpn44.prd.vienna.ovpn.com",
|
||||
Online: true,
|
||||
PublicKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||
WireguardPorts: []uint16{9929},
|
||||
},
|
||||
}},
|
||||
},
|
||||
|
||||
@@ -46,19 +46,12 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
openVPNServer.VPN = vpn.OpenVPN
|
||||
openVPNServer.TCP = true
|
||||
openVPNServer.UDP = true
|
||||
multiHopOpenVPNServer := openVPNServer
|
||||
multiHopOpenVPNServer.MultiHop = true
|
||||
multiHopOpenVPNServer.PortsTCP = []uint16{apiServer.MultiHopOpenvpnPort}
|
||||
multiHopOpenVPNServer.PortsUDP = []uint16{apiServer.MultiHopOpenvpnPort}
|
||||
servers = append(servers, openVPNServer, multiHopOpenVPNServer)
|
||||
servers = append(servers, openVPNServer)
|
||||
|
||||
wireguardServer := baseServer
|
||||
wireguardServer.VPN = vpn.Wireguard
|
||||
wireguardServer.WgPubKey = apiServer.PublicKey
|
||||
multiHopWireguardServer := wireguardServer
|
||||
multiHopWireguardServer.MultiHop = true
|
||||
multiHopWireguardServer.PortsUDP = []uint16{apiServer.MultiHopWireguardPort}
|
||||
servers = append(servers, wireguardServer, multiHopWireguardServer)
|
||||
servers = append(servers, wireguardServer)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
errMessage: "validating data center 1 of 1: data center Vienna: country name is not set",
|
||||
},
|
||||
"not_enough_servers": {
|
||||
minServers: 5,
|
||||
minServers: 3,
|
||||
responseStatus: http.StatusOK,
|
||||
responseBody: `{
|
||||
"success": true,
|
||||
@@ -81,10 +81,10 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
]
|
||||
}`,
|
||||
errWrapped: common.ErrNotEnoughServers,
|
||||
errMessage: "not enough servers found: 4 and expected at least 5",
|
||||
errMessage: "not enough servers found: 2 and expected at least 3",
|
||||
},
|
||||
"success": {
|
||||
minServers: 4,
|
||||
minServers: 2,
|
||||
responseBody: `{
|
||||
"success": true,
|
||||
"datacenters": [
|
||||
@@ -136,18 +136,6 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
UDP: true,
|
||||
TCP: true,
|
||||
},
|
||||
{
|
||||
Country: "Austria",
|
||||
City: "Vienna",
|
||||
Hostname: "vpn44.prd.vienna.ovpn.com",
|
||||
IPs: []netip.Addr{netip.MustParseAddr("37.120.212.227")},
|
||||
VPN: vpn.OpenVPN,
|
||||
UDP: true,
|
||||
TCP: true,
|
||||
MultiHop: true,
|
||||
PortsTCP: []uint16{20044},
|
||||
PortsUDP: []uint16{20044},
|
||||
},
|
||||
{
|
||||
Country: "Austria",
|
||||
City: "Vienna",
|
||||
@@ -156,16 +144,6 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
VPN: vpn.Wireguard,
|
||||
WgPubKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||
},
|
||||
{
|
||||
Country: "Austria",
|
||||
City: "Vienna",
|
||||
Hostname: "vpn44.prd.vienna.ovpn.com",
|
||||
IPs: []netip.Addr{netip.MustParseAddr("37.120.212.227")},
|
||||
VPN: vpn.Wireguard,
|
||||
WgPubKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||
MultiHop: true,
|
||||
PortsUDP: []uint16{30044},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user