Feature: Hide My Ass VPN provider support (#401)

This commit is contained in:
Quentin McGaw
2021-03-05 22:45:54 -05:00
committed by GitHub
parent 8b36ce198f
commit be72f4a046
23 changed files with 924 additions and 8 deletions

View File

@@ -0,0 +1,61 @@
package configuration
import (
"github.com/qdm12/gluetun/internal/constants"
)
func (settings *Provider) hideMyAssLines() (lines []string) {
if len(settings.ServerSelection.Countries) > 0 {
lines = append(lines, lastIndent+"Countries: "+commaJoin(settings.ServerSelection.Countries))
}
if len(settings.ServerSelection.Regions) > 0 {
lines = append(lines, lastIndent+"Regions: "+commaJoin(settings.ServerSelection.Regions))
}
if len(settings.ServerSelection.Cities) > 0 {
lines = append(lines, lastIndent+"Cities: "+commaJoin(settings.ServerSelection.Cities))
}
if len(settings.ServerSelection.Hostnames) > 0 {
lines = append(lines, lastIndent+"Hostnames: "+commaJoin(settings.ServerSelection.Hostnames))
}
return lines
}
func (settings *Provider) readHideMyAss(r reader) (err error) {
settings.Name = constants.HideMyAss
settings.ServerSelection.Protocol, err = readProtocol(r.env)
if err != nil {
return err
}
settings.ServerSelection.TargetIP, err = readTargetIP(r.env)
if err != nil {
return err
}
settings.ServerSelection.Countries, err = r.env.CSVInside("COUNTRY", constants.HideMyAssCountryChoices())
if err != nil {
return err
}
settings.ServerSelection.Regions, err = r.env.CSVInside("REGION", constants.HideMyAssCountryChoices())
if err != nil {
return err
}
settings.ServerSelection.Cities, err = r.env.CSVInside("CITY", constants.HideMyAssCityChoices())
if err != nil {
return err
}
settings.ServerSelection.Hostnames, err = r.env.CSVInside("SERVER_HOSTNAME", constants.TorguardHostnamesChoices())
if err != nil {
return err
}
return nil
}

View File

@@ -56,7 +56,7 @@ var (
func (settings *OpenVPN) read(r reader) (err error) {
vpnsp, err := r.env.Inside("VPNSP", []string{
"cyberghost", "mullvad", "nordvpn", "privado",
"cyberghost", "hidemyass", "mullvad", "nordvpn", "privado",
"pia", "private internet access", "purevpn", "surfshark",
"torguard", "vyprvpn", "windscribe"},
params.Default("private internet access"))
@@ -115,6 +115,8 @@ func (settings *OpenVPN) read(r reader) (err error) {
switch settings.Provider.Name {
case constants.Cyberghost:
readProvider = settings.Provider.readCyberghost
case constants.HideMyAss:
readProvider = settings.Provider.readHideMyAss
case constants.Mullvad:
readProvider = settings.Provider.readMullvad
case constants.Nordvpn:

View File

@@ -31,6 +31,8 @@ func (settings *Provider) lines() (lines []string) {
switch strings.ToLower(settings.Name) {
case "cyberghost":
providerLines = settings.cyberghostLines()
case "hidemyass":
providerLines = settings.hideMyAssLines()
case "mullvad":
providerLines = settings.mullvadLines()
case "nordvpn":

View File

@@ -42,6 +42,24 @@ func Test_Provider_lines(t *testing.T) {
" |--Client certificate is set",
},
},
"hidemyass": {
settings: Provider{
Name: constants.HideMyAss,
ServerSelection: ServerSelection{
Protocol: constants.UDP,
Countries: []string{"a", "b"},
Cities: []string{"c", "d"},
Hostnames: []string{"e", "f"},
},
},
lines: []string{
"|--Hidemyass settings:",
" |--Network protocol: udp",
" |--Countries: a, b",
" |--Cities: c, d",
" |--Hostnames: e, f",
},
},
"mullvad": {
settings: Provider{
Name: constants.Mullvad,

View File

@@ -15,9 +15,9 @@ type ServerSelection struct {
// Cyberghost
Group string `json:"group"`
Countries []string `json:"countries"` // Mullvad, PureVPN
Cities []string `json:"cities"` // Mullvad, PureVPN, Windscribe
Hostnames []string `json:"hostnames"` // Windscribe, Privado
Countries []string `json:"countries"` // HideMyAss, Mullvad, PureVPN
Cities []string `json:"cities"` // HideMyAss, Mullvad, PureVPN, Windscribe
Hostnames []string `json:"hostnames"` // HideMyAss, Windscribe, Privado
// Mullvad
ISPs []string `json:"isps"`

View File

@@ -11,6 +11,7 @@ type Updater struct {
Period time.Duration `json:"period"`
DNSAddress string `json:"dns_address"`
Cyberghost bool `json:"cyberghost"`
HideMyAss bool `json:"hidemyass"`
Mullvad bool `json:"mullvad"`
Nordvpn bool `json:"nordvpn"`
PIA bool `json:"pia"`
@@ -43,6 +44,7 @@ func (settings *Updater) lines() (lines []string) {
func (settings *Updater) read(r reader) (err error) {
settings.Cyberghost = true
settings.HideMyAss = true
settings.Mullvad = true
settings.Nordvpn = true
settings.Privado = true