Remove support for multihop
This commit is contained in:
@@ -29,8 +29,6 @@ type apiServer struct {
|
|||||||
Online bool `json:"online"`
|
Online bool `json:"online"`
|
||||||
PublicKey string `json:"public_key"`
|
PublicKey string `json:"public_key"`
|
||||||
WireguardPorts []uint16 `json:"wireguard_ports"`
|
WireguardPorts []uint16 `json:"wireguard_ports"`
|
||||||
MultiHopOpenvpnPort uint16 `json:"multihop_openvpn_port"`
|
|
||||||
MultiHopWireguardPort uint16 `json:"multihop_wireguard_port"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func fetchAPI(ctx context.Context, client *http.Client) (
|
func fetchAPI(ctx context.Context, client *http.Client) (
|
||||||
@@ -114,8 +112,6 @@ var (
|
|||||||
ErrPublicKeyFieldNotSet = errors.New("public key field is not set")
|
ErrPublicKeyFieldNotSet = errors.New("public key field is not set")
|
||||||
ErrWireguardPortsNotSet = errors.New("wireguard ports array is not set")
|
ErrWireguardPortsNotSet = errors.New("wireguard ports array is not set")
|
||||||
ErrWireguardPortNotDefault = errors.New("wireguard port is not the default 9929")
|
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")
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func (a *apiServer) validate() (err error) {
|
func (a *apiServer) validate() (err error) {
|
||||||
@@ -129,8 +125,6 @@ func (a *apiServer) validate() (err error) {
|
|||||||
err: ErrWireguardPortNotDefault,
|
err: ErrWireguardPortNotDefault,
|
||||||
condition: len(a.WireguardPorts) != 1 || a.WireguardPorts[0] != defaultWireguardPort,
|
condition: len(a.WireguardPorts) != 1 || a.WireguardPorts[0] != defaultWireguardPort,
|
||||||
},
|
},
|
||||||
{err: ErrMultiHopOpenVPNPortNotSet, condition: a.MultiHopOpenvpnPort == 0},
|
|
||||||
{err: ErrMultiHopWireguardPortNotSet, condition: a.MultiHopWireguardPort == 0},
|
|
||||||
}
|
}
|
||||||
err = collectErrors(conditionalErrors)
|
err = collectErrors(conditionalErrors)
|
||||||
switch {
|
switch {
|
||||||
|
|||||||
@@ -77,8 +77,6 @@ func Test_fetchAPI(t *testing.T) {
|
|||||||
Online: true,
|
Online: true,
|
||||||
PublicKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
PublicKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||||
WireguardPorts: []uint16{9929},
|
WireguardPorts: []uint16{9929},
|
||||||
MultiHopOpenvpnPort: 20044,
|
|
||||||
MultiHopWireguardPort: 30044,
|
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -46,19 +46,12 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
|||||||
openVPNServer.VPN = vpn.OpenVPN
|
openVPNServer.VPN = vpn.OpenVPN
|
||||||
openVPNServer.TCP = true
|
openVPNServer.TCP = true
|
||||||
openVPNServer.UDP = true
|
openVPNServer.UDP = true
|
||||||
multiHopOpenVPNServer := openVPNServer
|
servers = append(servers, openVPNServer)
|
||||||
multiHopOpenVPNServer.MultiHop = true
|
|
||||||
multiHopOpenVPNServer.PortsTCP = []uint16{apiServer.MultiHopOpenvpnPort}
|
|
||||||
multiHopOpenVPNServer.PortsUDP = []uint16{apiServer.MultiHopOpenvpnPort}
|
|
||||||
servers = append(servers, openVPNServer, multiHopOpenVPNServer)
|
|
||||||
|
|
||||||
wireguardServer := baseServer
|
wireguardServer := baseServer
|
||||||
wireguardServer.VPN = vpn.Wireguard
|
wireguardServer.VPN = vpn.Wireguard
|
||||||
wireguardServer.WgPubKey = apiServer.PublicKey
|
wireguardServer.WgPubKey = apiServer.PublicKey
|
||||||
multiHopWireguardServer := wireguardServer
|
servers = append(servers, wireguardServer)
|
||||||
multiHopWireguardServer.MultiHop = true
|
|
||||||
multiHopWireguardServer.PortsUDP = []uint16{apiServer.MultiHopWireguardPort}
|
|
||||||
servers = append(servers, wireguardServer, multiHopWireguardServer)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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",
|
errMessage: "validating data center 1 of 1: data center Vienna: country name is not set",
|
||||||
},
|
},
|
||||||
"not_enough_servers": {
|
"not_enough_servers": {
|
||||||
minServers: 5,
|
minServers: 3,
|
||||||
responseStatus: http.StatusOK,
|
responseStatus: http.StatusOK,
|
||||||
responseBody: `{
|
responseBody: `{
|
||||||
"success": true,
|
"success": true,
|
||||||
@@ -81,10 +81,10 @@ func Test_Updater_FetchServers(t *testing.T) {
|
|||||||
]
|
]
|
||||||
}`,
|
}`,
|
||||||
errWrapped: common.ErrNotEnoughServers,
|
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": {
|
"success": {
|
||||||
minServers: 4,
|
minServers: 2,
|
||||||
responseBody: `{
|
responseBody: `{
|
||||||
"success": true,
|
"success": true,
|
||||||
"datacenters": [
|
"datacenters": [
|
||||||
@@ -136,18 +136,6 @@ func Test_Updater_FetchServers(t *testing.T) {
|
|||||||
UDP: true,
|
UDP: true,
|
||||||
TCP: 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",
|
Country: "Austria",
|
||||||
City: "Vienna",
|
City: "Vienna",
|
||||||
@@ -156,16 +144,6 @@ func Test_Updater_FetchServers(t *testing.T) {
|
|||||||
VPN: vpn.Wireguard,
|
VPN: vpn.Wireguard,
|
||||||
WgPubKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
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