mirror of
https://github.com/qdm12/gluetun.git
synced 2026-06-10 14:22:30 +02:00
SERVER_DEDICATED option
This commit is contained in:
@@ -22,13 +22,16 @@ 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 is for the Standard Shared Entry Point
|
||||
PublicKey string `json:"public_key"`
|
||||
// PublicKeyIPv4 is for the Public / Dedicated IP Entry Point
|
||||
PublicKeyIPv4 string `json:"public_key_ipv4"`
|
||||
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) (
|
||||
@@ -106,6 +109,7 @@ func (a *apiServer) validate() (err error) {
|
||||
{err: "ip address is not set", condition: !a.IP.IsValid()},
|
||||
{err: "hostname field is not set", condition: a.Ptr == ""},
|
||||
{err: "public key field is not set", condition: a.PublicKey == ""},
|
||||
{err: "public key IPv4 field is not set", condition: a.PublicKeyIPv4 == ""},
|
||||
{err: "wireguard ports array is not set", condition: len(a.WireguardPorts) == 0},
|
||||
{
|
||||
err: "wireguard port is not the default 9929",
|
||||
|
||||
@@ -76,6 +76,7 @@ func Test_fetchAPI(t *testing.T) {
|
||||
Ptr: "vpn44.prd.vienna.ovpn.com",
|
||||
Online: true,
|
||||
PublicKey: "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||
PublicKeyIPv4: "wFbSRyjSXBmkjJodlqz7DoYn3WNDPYFUIXyIUS2QU2A=",
|
||||
WireguardPorts: []uint16{9929},
|
||||
MultiHopOpenvpnPort: 20044,
|
||||
MultiHopWireguardPort: 30044,
|
||||
|
||||
@@ -56,7 +56,18 @@ func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
||||
multiHopWireguardServer := wireguardServer
|
||||
multiHopWireguardServer.MultiHop = true
|
||||
multiHopWireguardServer.PortsUDP = []uint16{apiServer.MultiHopWireguardPort}
|
||||
servers = append(servers, wireguardServer, multiHopWireguardServer)
|
||||
dedicatedWireguardServer := wireguardServer
|
||||
dedicatedWireguardServer.WgPubKey = apiServer.PublicKeyIPv4
|
||||
dedicatedWireguardServer.Dedicated = true
|
||||
dedicatedMultiHopWireguardServer := multiHopWireguardServer
|
||||
dedicatedMultiHopWireguardServer.WgPubKey = apiServer.PublicKeyIPv4
|
||||
dedicatedMultiHopWireguardServer.Dedicated = true
|
||||
servers = append(servers,
|
||||
wireguardServer,
|
||||
multiHopWireguardServer,
|
||||
dedicatedWireguardServer,
|
||||
dedicatedMultiHopWireguardServer,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -55,7 +55,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: 7,
|
||||
responseStatus: http.StatusOK,
|
||||
responseBody: `{
|
||||
"success": true,
|
||||
@@ -69,6 +69,7 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
"ptr": "vpn44.prd.vienna.ovpn.com",
|
||||
"online": true,
|
||||
"public_key": "r83LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||
"public_key_ipv4": "wFbSRyjSXBmkjJodlqz7DoYn3WNDPYFUIXyIUS2QU2A=",
|
||||
"wireguard_ports": [9929],
|
||||
"multihop_openvpn_port": 20044,
|
||||
"multihop_wireguard_port": 30044
|
||||
@@ -78,7 +79,9 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
]
|
||||
}`,
|
||||
errWrapped: common.ErrNotEnoughServers,
|
||||
errMessage: "not enough servers found: 4 and expected at least 5",
|
||||
// Wireguard + dedicated Wireguard + Wireguard multi-hop +
|
||||
// dedicated Wireguard multi-hop + OpenVPN + OpenVPN multi-hop
|
||||
errMessage: "not enough servers found: 6 and expected at least 7",
|
||||
},
|
||||
"success": {
|
||||
minServers: 4,
|
||||
@@ -114,6 +117,7 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
"ptr": "vpn45.prd.vienna.ovpn.com",
|
||||
"online": false,
|
||||
"public_key": "r93LIc0Q2F8s3dY9x5y17Yz8wTADJc7giW1t5eSmoXc=",
|
||||
"public_key_ipv4": "wGbSRyjSXBmkjJodlqz7DoYn3WNDPYFUIXyIUS2QU2A=",
|
||||
"wireguard_ports": [9929],
|
||||
"multihop_openvpn_port": 20045,
|
||||
"multihop_wireguard_port": 30045
|
||||
@@ -163,6 +167,26 @@ func Test_Updater_FetchServers(t *testing.T) {
|
||||
MultiHop: true,
|
||||
PortsUDP: []uint16{30044},
|
||||
},
|
||||
{
|
||||
Country: "Austria",
|
||||
City: "Vienna",
|
||||
Hostname: "vpn44.prd.vienna.ovpn.com",
|
||||
IPs: []netip.Addr{netip.MustParseAddr("37.120.212.227")},
|
||||
VPN: vpn.Wireguard,
|
||||
WgPubKey: "wFbSRyjSXBmkjJodlqz7DoYn3WNDPYFUIXyIUS2QU2A=",
|
||||
Dedicated: true,
|
||||
},
|
||||
{
|
||||
Country: "Austria",
|
||||
City: "Vienna",
|
||||
Hostname: "vpn44.prd.vienna.ovpn.com",
|
||||
IPs: []netip.Addr{netip.MustParseAddr("37.120.212.227")},
|
||||
VPN: vpn.Wireguard,
|
||||
WgPubKey: "wFbSRyjSXBmkjJodlqz7DoYn3WNDPYFUIXyIUS2QU2A=",
|
||||
MultiHop: true,
|
||||
Dedicated: true,
|
||||
PortsUDP: []uint16{30044},
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user