Maint: migrate Cyberghost REGION to COUNTRY
This commit is contained in:
@@ -4,6 +4,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants"
|
||||
"github.com/qdm12/golibs/params"
|
||||
)
|
||||
|
||||
func (settings *Provider) readCyberghost(r reader) (err error) {
|
||||
@@ -21,9 +22,11 @@ func (settings *Provider) readCyberghost(r reader) (err error) {
|
||||
return fmt.Errorf("environment variable CYBERGHOST_GROUP: %w", err)
|
||||
}
|
||||
|
||||
settings.ServerSelection.Regions, err = r.env.CSVInside("REGION", constants.CyberghostRegionChoices(servers))
|
||||
settings.ServerSelection.Countries, err = r.env.CSVInside("COUNTRY",
|
||||
constants.CyberghostCountryChoices(servers),
|
||||
params.RetroKeys([]string{"REGION"}, r.onRetroActive))
|
||||
if err != nil {
|
||||
return fmt.Errorf("environment variable REGION: %w", err)
|
||||
return fmt.Errorf("environment variable COUNTRY: %w", err)
|
||||
}
|
||||
|
||||
settings.ServerSelection.Hostnames, err = r.env.CSVInside("SERVER_HOSTNAME",
|
||||
|
||||
@@ -24,15 +24,15 @@ func Test_Provider_lines(t *testing.T) {
|
||||
settings: Provider{
|
||||
Name: constants.Cyberghost,
|
||||
ServerSelection: ServerSelection{
|
||||
VPN: constants.OpenVPN,
|
||||
Groups: []string{"group"},
|
||||
Regions: []string{"a", "El country"},
|
||||
VPN: constants.OpenVPN,
|
||||
Groups: []string{"group"},
|
||||
Countries: []string{"a", "El country"},
|
||||
},
|
||||
},
|
||||
lines: []string{
|
||||
"|--Cyberghost settings:",
|
||||
" |--Server groups: group",
|
||||
" |--Regions: a, El country",
|
||||
" |--Countries: a, El country",
|
||||
" |--OpenVPN selection:",
|
||||
" |--Protocol: udp",
|
||||
},
|
||||
|
||||
@@ -11,10 +11,10 @@ const (
|
||||
CyberghostCertificate = "MIIGWjCCBEKgAwIBAgIJAJxUG61mxDS7MA0GCSqGSIb3DQEBDQUAMHsxCzAJBgNVBAYTAlJPMRIwEAYDVQQHE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yberghostServer) (choices []string) {
|
||||
func CyberghostCountryChoices(servers []models.CyberghostServer) (choices []string) {
|
||||
choices = make([]string, len(servers))
|
||||
for i := range servers {
|
||||
choices[i] = servers[i].Region
|
||||
choices[i] = servers[i].Country
|
||||
}
|
||||
return makeUnique(choices)
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ func markdownTableHeading(legendFields ...string) (markdown string) {
|
||||
}
|
||||
|
||||
func (s *CyberghostServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Region", "Group", "Hostname")
|
||||
markdown = markdownTableHeading("Country", "Group", "Hostname")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
@@ -26,7 +26,7 @@ func (s *CyberghostServers) ToMarkdown() (markdown string) {
|
||||
}
|
||||
|
||||
func (s CyberghostServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | `%s` |", s.Region, s.Group, s.Hostname)
|
||||
return fmt.Sprintf("| %s | %s | `%s` |", s.Country, s.Group, s.Hostname)
|
||||
}
|
||||
|
||||
func (s *FastestvpnServers) ToMarkdown() (markdown string) {
|
||||
|
||||
@@ -11,13 +11,13 @@ func Test_CyberghostServers_ToMarkdown(t *testing.T) {
|
||||
|
||||
servers := CyberghostServers{
|
||||
Servers: []CyberghostServer{
|
||||
{Region: "a", Group: "A", Hostname: "xa"},
|
||||
{Region: "b", Group: "A", Hostname: "xb"},
|
||||
{Country: "a", Group: "A", Hostname: "xa"},
|
||||
{Country: "b", Group: "A", Hostname: "xb"},
|
||||
},
|
||||
}
|
||||
|
||||
markdown := servers.ToMarkdown()
|
||||
const expected = "| Region | Group | Hostname |\n" +
|
||||
const expected = "| Country | Group | Hostname |\n" +
|
||||
"| --- | --- | --- |\n" +
|
||||
"| a | A | `xa` |\n" +
|
||||
"| b | A | `xb` |\n"
|
||||
|
||||
@@ -5,7 +5,7 @@ import (
|
||||
)
|
||||
|
||||
type CyberghostServer struct {
|
||||
Region string `json:"region"`
|
||||
Country string `json:"country"`
|
||||
Group string `json:"group"`
|
||||
Hostname string `json:"hostname"`
|
||||
IPs []net.IP `json:"ips"`
|
||||
|
||||
@@ -36,7 +36,7 @@ func (c *Cyberghost) filterServers(selection configuration.ServerSelection) (
|
||||
switch {
|
||||
case
|
||||
utils.FilterByPossibilities(server.Group, selection.Groups),
|
||||
utils.FilterByPossibilities(server.Region, selection.Regions),
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames):
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
|
||||
@@ -25,22 +25,22 @@ func Test_Cyberghost_filterServers(t *testing.T) {
|
||||
},
|
||||
"servers without filter defaults to UDP": {
|
||||
servers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium TCP Asia"},
|
||||
{Region: "b", Group: "Premium TCP Europe"},
|
||||
{Region: "c", Group: "Premium UDP Asia"},
|
||||
{Region: "d", Group: "Premium UDP Europe"},
|
||||
{Country: "a", Group: "Premium TCP Asia"},
|
||||
{Country: "b", Group: "Premium TCP Europe"},
|
||||
{Country: "c", Group: "Premium UDP Asia"},
|
||||
{Country: "d", Group: "Premium UDP Europe"},
|
||||
},
|
||||
filteredServers: []models.CyberghostServer{
|
||||
{Region: "c", Group: "Premium UDP Asia"},
|
||||
{Region: "d", Group: "Premium UDP Europe"},
|
||||
{Country: "c", Group: "Premium UDP Asia"},
|
||||
{Country: "d", Group: "Premium UDP Europe"},
|
||||
},
|
||||
},
|
||||
"servers with TCP selection": {
|
||||
servers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium TCP Asia"},
|
||||
{Region: "b", Group: "Premium TCP Europe"},
|
||||
{Region: "c", Group: "Premium UDP Asia"},
|
||||
{Region: "d", Group: "Premium UDP Europe"},
|
||||
{Country: "a", Group: "Premium TCP Asia"},
|
||||
{Country: "b", Group: "Premium TCP Europe"},
|
||||
{Country: "c", Group: "Premium UDP Asia"},
|
||||
{Country: "d", Group: "Premium UDP Europe"},
|
||||
},
|
||||
selection: configuration.ServerSelection{
|
||||
OpenVPN: configuration.OpenVPNSelection{
|
||||
@@ -48,46 +48,46 @@ func Test_Cyberghost_filterServers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
filteredServers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium TCP Asia"},
|
||||
{Region: "b", Group: "Premium TCP Europe"},
|
||||
{Country: "a", Group: "Premium TCP Asia"},
|
||||
{Country: "b", Group: "Premium TCP Europe"},
|
||||
},
|
||||
},
|
||||
"servers with regions filter": {
|
||||
servers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium UDP Asia"},
|
||||
{Region: "b", Group: "Premium UDP Asia"},
|
||||
{Region: "c", Group: "Premium UDP Asia"},
|
||||
{Region: "d", Group: "Premium UDP Asia"},
|
||||
{Country: "a", Group: "Premium UDP Asia"},
|
||||
{Country: "b", Group: "Premium UDP Asia"},
|
||||
{Country: "c", Group: "Premium UDP Asia"},
|
||||
{Country: "d", Group: "Premium UDP Asia"},
|
||||
},
|
||||
selection: configuration.ServerSelection{
|
||||
Regions: []string{"a", "c"},
|
||||
Countries: []string{"a", "c"},
|
||||
},
|
||||
filteredServers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium UDP Asia"},
|
||||
{Region: "c", Group: "Premium UDP Asia"},
|
||||
{Country: "a", Group: "Premium UDP Asia"},
|
||||
{Country: "c", Group: "Premium UDP Asia"},
|
||||
},
|
||||
},
|
||||
"servers with group filter": {
|
||||
servers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium UDP Europe"},
|
||||
{Region: "b", Group: "Premium UDP Europe"},
|
||||
{Region: "c", Group: "Premium TCP Europe"},
|
||||
{Region: "d", Group: "Premium TCP Europe"},
|
||||
{Country: "a", Group: "Premium UDP Europe"},
|
||||
{Country: "b", Group: "Premium UDP Europe"},
|
||||
{Country: "c", Group: "Premium TCP Europe"},
|
||||
{Country: "d", Group: "Premium TCP Europe"},
|
||||
},
|
||||
selection: configuration.ServerSelection{
|
||||
Groups: []string{"Premium UDP Europe"},
|
||||
},
|
||||
filteredServers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium UDP Europe"},
|
||||
{Region: "b", Group: "Premium UDP Europe"},
|
||||
{Country: "a", Group: "Premium UDP Europe"},
|
||||
{Country: "b", Group: "Premium UDP Europe"},
|
||||
},
|
||||
},
|
||||
"servers with bad group filter": {
|
||||
servers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium TCP Europe"},
|
||||
{Region: "b", Group: "Premium TCP Europe"},
|
||||
{Region: "c", Group: "Premium UDP Europe"},
|
||||
{Region: "d", Group: "Premium UDP Europe"},
|
||||
{Country: "a", Group: "Premium TCP Europe"},
|
||||
{Country: "b", Group: "Premium TCP Europe"},
|
||||
{Country: "c", Group: "Premium UDP Europe"},
|
||||
{Country: "d", Group: "Premium UDP Europe"},
|
||||
},
|
||||
selection: configuration.ServerSelection{
|
||||
Groups: []string{"Premium TCP Europe"},
|
||||
@@ -96,17 +96,17 @@ func Test_Cyberghost_filterServers(t *testing.T) {
|
||||
},
|
||||
"servers with regions and group filter": {
|
||||
servers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium UDP Europe"},
|
||||
{Region: "b", Group: "Premium TCP Europe"},
|
||||
{Region: "c", Group: "Premium UDP Asia"},
|
||||
{Region: "d", Group: "Premium TCP Asia"},
|
||||
{Country: "a", Group: "Premium UDP Europe"},
|
||||
{Country: "b", Group: "Premium TCP Europe"},
|
||||
{Country: "c", Group: "Premium UDP Asia"},
|
||||
{Country: "d", Group: "Premium TCP Asia"},
|
||||
},
|
||||
selection: configuration.ServerSelection{
|
||||
Regions: []string{"a", "c"},
|
||||
Groups: []string{"Premium UDP Europe"},
|
||||
Countries: []string{"a", "c"},
|
||||
Groups: []string{"Premium UDP Europe"},
|
||||
},
|
||||
filteredServers: []models.CyberghostServer{
|
||||
{Region: "a", Group: "Premium UDP Europe"},
|
||||
{Country: "a", Group: "Premium UDP Europe"},
|
||||
},
|
||||
},
|
||||
"servers with hostnames filter": {
|
||||
|
||||
@@ -51,7 +51,7 @@ func Test_versions(t *testing.T) {
|
||||
"Cyberghost": {
|
||||
model: models.CyberghostServer{},
|
||||
version: allServers.Cyberghost.Version,
|
||||
digest: "229828de",
|
||||
digest: "c2f6f43b",
|
||||
},
|
||||
"Fastestvpn": {
|
||||
model: models.FastestvpnServer{},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -21,12 +21,12 @@ func getPossibleServers() (possibleServers hostToServer) {
|
||||
possibleServers = make(hostToServer, n) // key is the host
|
||||
|
||||
for groupID, groupName := range groups {
|
||||
for countryCode, region := range possibleCountryCodes {
|
||||
for countryCode, country := range possibleCountryCodes {
|
||||
const domain = "cg-dialup.net"
|
||||
possibleHost := groupID + "-" + countryCode + "." + domain
|
||||
possibleServer := models.CyberghostServer{
|
||||
Hostname: possibleHost,
|
||||
Region: region,
|
||||
Country: country,
|
||||
Group: groupName,
|
||||
}
|
||||
possibleServers[possibleHost] = possibleServer
|
||||
|
||||
@@ -8,12 +8,12 @@ import (
|
||||
|
||||
func sortServers(servers []models.CyberghostServer) {
|
||||
sort.Slice(servers, func(i, j int) bool {
|
||||
if servers[i].Region == servers[j].Region {
|
||||
if servers[i].Country == servers[j].Country {
|
||||
if servers[i].Group == servers[j].Group {
|
||||
return servers[i].Hostname < servers[j].Hostname
|
||||
}
|
||||
return servers[i].Group < servers[j].Group
|
||||
}
|
||||
return servers[i].Region < servers[j].Region
|
||||
return servers[i].Country < servers[j].Country
|
||||
})
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@
|
||||
- `PIA_ENCRYPTION`
|
||||
- `PORT_FORWARDING`
|
||||
- `WIREGUARD_PORT`
|
||||
- `REGION` for PIA
|
||||
- `REGION` for PIA, Cyberghost
|
||||
- `WIREGUARD_ADDRESS`
|
||||
- `VPNSP`
|
||||
- All old location filters such as `REGION`, `COUNTRY`, etc.
|
||||
|
||||
Reference in New Issue
Block a user