Refactored region parsing for PIA

This commit is contained in:
Quentin McGaw (desktop)
2020-02-10 18:17:22 +00:00
parent 77c6eeb765
commit 66667f94e1
4 changed files with 71 additions and 161 deletions

View File

@@ -1,6 +1,9 @@
package constants package constants
import ( import (
"fmt"
"strings"
"github.com/qdm12/private-internet-access-docker/internal/models" "github.com/qdm12/private-internet-access-docker/internal/models"
) )
@@ -18,163 +21,68 @@ const (
PIACertificate_STRONG = "MIIHqzCCBZOgAwIBAgIJAJ0u+vODZJntMA0GCSqGSIb3DQEBDQUAMIHoMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNVBAoTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UEAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBCkTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkBFiBzZWN1cmVAcHJpdmF0ZWludGVybmV0YWNjZXNzLmNvbTAeFw0xNDA0MTcxNzQwMzNaFw0zNDA0MTIxNzQwMzNaMIHoMQswCQYDVQQGEwJVUzELMAkGA1UECBMCQ0ExEzARBgNVBAcTCkxvc0FuZ2VsZXMxIDAeBgNVBAoTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMSAwHgYDVQQLExdQcml2YXRlIEludGVybmV0IEFjY2VzczEgMB4GA1UEAxMXUHJpdmF0ZSBJbnRlcm5ldCBBY2Nlc3MxIDAeBgNVBCkTF1ByaXZhdGUgSW50ZXJuZXQgQWNjZXNzMS8wLQYJKoZIhvcNAQkBFiBzZWN1cmVAcHJpdmF0ZWludGVybmV0YWNjZXNzLmNvbTCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBALVkhjumaqBbL8aSgj6xbX1QPTfTd1qHsAZd2B97m8Vw31c/2yQgZNf5qZY0+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XDROLhISLQDRjVVAvawrAtLZWYK31bY7KlezPlQnl/D9Asxe85l8jO5+0LdJ6VyOs/Hd4w52alDW/MFySDZSfQHMTIc30hLBJ8OnCEIvluVQQ2UQvoW+no177N9L2Y+M9TcTA62ZyMXShHQGeh20rb4kK8f+iFX8NxtdHVSkxMEFSfDDyQ="
) )
const ( func PIAGeoChoices() []string {
AUMelbourne models.PIARegion = "AU Melbourne" return []string{"AU Melbourne", "AU Perth", "AU Sydney", "Austria", "Belgium", "CA Montreal", "CA Toronto", "CA Vancouver", "Czech Republic", "DE Berlin", "DE Frankfurt", "Denmark", "Finland", "France", "Hong Kong", "Hungary", "India", "Ireland", "Israel", "Italy", "Japan", "Luxembourg", "Mexico", "Netherlands", "New Zealand", "Norway", "Poland", "Romania", "Singapore", "Spain", "Sweden", "Switzerland", "UAE", "UK London", "UK Manchester", "UK Southampton", "US Atlanta", "US California", "US Chicago", "US Denver", "US East", "US Florida", "US Houston", "US Las Vegas", "US New York City", "US Seattle", "US Silicon Valley", "US Texas", "US Washington DC", "US West"}
AUPerth models.PIARegion = "AU Perth" }
AUSydney models.PIARegion = "AU Sydney"
Austria models.PIARegion = "Austria"
Belgium models.PIARegion = "Belgium"
CAMontreal models.PIARegion = "CA Montreal"
CAToronto models.PIARegion = "CA Toronto"
CAVancouver models.PIARegion = "CA Vancouver"
CzechRepublic models.PIARegion = "Czech Republic"
DEBerlin models.PIARegion = "DE Berlin"
DEFrankfurt models.PIARegion = "DE Frankfurt"
Denmark models.PIARegion = "Denmark"
Finland models.PIARegion = "Finland"
France models.PIARegion = "France"
HongKong models.PIARegion = "Hong Kong"
Hungary models.PIARegion = "Hungary"
India models.PIARegion = "India"
Ireland models.PIARegion = "Ireland"
Israel models.PIARegion = "Israel"
Italy models.PIARegion = "Italy"
Japan models.PIARegion = "Japan"
Luxembourg models.PIARegion = "Luxembourg"
Mexico models.PIARegion = "Mexico"
Netherlands models.PIARegion = "Netherlands"
NewZealand models.PIARegion = "New Zealand"
Norway models.PIARegion = "Norway"
Poland models.PIARegion = "Poland"
Romania models.PIARegion = "Romania"
Singapore models.PIARegion = "Singapore"
Spain models.PIARegion = "Spain"
Sweden models.PIARegion = "Sweden"
Switzerland models.PIARegion = "Switzerland"
UAE models.PIARegion = "UAE"
UKLondon models.PIARegion = "UK London"
UKManchester models.PIARegion = "UK Manchester"
UKSouthampton models.PIARegion = "UK Southampton"
USAtlanta models.PIARegion = "US Atlanta"
USCalifornia models.PIARegion = "US California"
USChicago models.PIARegion = "US Chicago"
USDenver models.PIARegion = "US Denver"
USEast models.PIARegion = "US East"
USFlorida models.PIARegion = "US Florida"
USHouston models.PIARegion = "US Houston"
USLasVegas models.PIARegion = "US Las Vegas"
USNewYorkCity models.PIARegion = "US New York City"
USSeattle models.PIARegion = "US Seattle"
USSiliconValley models.PIARegion = "US Silicon Valley"
USTexas models.PIARegion = "US Texas"
USWashingtonDC models.PIARegion = "US Washington DC"
USWest models.PIARegion = "US West"
)
const ( func PIAGeoToSubdomainMapping(region models.PIARegion) (subdomain string, err error) {
PIASubdomainAUMelbourne string = "au-melbourne" mapping := map[models.PIARegion]string{
PIASubdomainAUPerth string = "au-perth" models.PIARegion("AU Melbourne"): "au-melbourne",
PIASubdomainAUSydney string = "au-sydney" models.PIARegion("AU Perth"): "au-perth",
PIASubdomainAustria string = "austria" models.PIARegion("AU Sydney"): "au-sydney",
PIASubdomainBelgium string = "belgium" models.PIARegion("Austria"): "austria",
PIASubdomainCAMontreal string = "ca-montreal" models.PIARegion("Belgium"): "belgium",
PIASubdomainCAToronto string = "ca-toronto" models.PIARegion("CA Montreal"): "ca-montreal",
PIASubdomainCAVancouver string = "ca-vancouver" models.PIARegion("CA Toronto"): "ca-toronto",
PIASubdomainCzechRepublic string = "czech" models.PIARegion("CA Vancouver"): "ca-vancouver",
PIASubdomainDEBerlin string = "de-berlin" models.PIARegion("Czech Republic"): "czech",
PIASubdomainDEFrankfurt string = "de-frankfurt" models.PIARegion("DE Berlin"): "de-berlin",
PIASubdomainDenmark string = "denmark" models.PIARegion("DE Frankfurt"): "de-frankfurt",
PIASubdomainFinland string = "fi" models.PIARegion("Denmark"): "denmark",
PIASubdomainFrance string = "france" models.PIARegion("Finland"): "fi",
PIASubdomainHongKong string = "hk" models.PIARegion("France"): "france",
PIASubdomainHungary string = "hungary" models.PIARegion("Hong Kong"): "hk",
PIASubdomainIndia string = "in" models.PIARegion("Hungary"): "hungary",
PIASubdomainIreland string = "ireland" models.PIARegion("India"): "in",
PIASubdomainIsrael string = "israel" models.PIARegion("Ireland"): "ireland",
PIASubdomainItaly string = "italy" models.PIARegion("Israel"): "israel",
PIASubdomainJapan string = "japan" models.PIARegion("Italy"): "italy",
PIASubdomainLuxembourg string = "lu" models.PIARegion("Japan"): "japan",
PIASubdomainMexico string = "mexico" models.PIARegion("Luxembourg"): "lu",
PIASubdomainNetherlands string = "nl" models.PIARegion("Mexico"): "mexico",
PIASubdomainNewZealand string = "nz" models.PIARegion("Netherlands"): "nl",
PIASubdomainNorway string = "no" models.PIARegion("New Zealand"): "nz",
PIASubdomainPoland string = "poland" models.PIARegion("Norway"): "no",
PIASubdomainRomania string = "ro" models.PIARegion("Poland"): "poland",
PIASubdomainSingapore string = "sg" models.PIARegion("Romania"): "ro",
PIASubdomainSpain string = "spain" models.PIARegion("Singapore"): "sg",
PIASubdomainSweden string = "sweden" models.PIARegion("Spain"): "spain",
PIASubdomainSwitzerland string = "swiss" models.PIARegion("Sweden"): "sweden",
PIASubdomainUAE string = "ae" models.PIARegion("Switzerland"): "swiss",
PIASubdomainUKLondon string = "uk-london" models.PIARegion("UAE"): "ae",
PIASubdomainUKManchester string = "uk-manchester" models.PIARegion("UK London"): "uk-london",
PIASubdomainUKSouthampton string = "uk-southampton" models.PIARegion("UK Manchester"): "uk-manchester",
PIASubdomainUSAtlanta string = "us-atlanta" models.PIARegion("UK Southampton"): "uk-southampton",
PIASubdomainUSCalifornia string = "us-california" models.PIARegion("US Atlanta"): "us-atlanta",
PIASubdomainUSChicago string = "us-chicago" models.PIARegion("US California"): "us-california",
PIASubdomainUSDenver string = "us-denver" models.PIARegion("US Chicago"): "us-chicago",
PIASubdomainUSEast string = "us-east" models.PIARegion("US Denver"): "us-denver",
PIASubdomainUSFlorida string = "us-florida" models.PIARegion("US East"): "us-east",
PIASubdomainUSHouston string = "us-houston" models.PIARegion("US Florida"): "us-florida",
PIASubdomainUSLasVegas string = "us-lasvegas" models.PIARegion("US Houston"): "us-houston",
PIASubdomainUSNewYorkCity string = "us-newyorkcity" models.PIARegion("US Las Vegas"): "us-lasvegas",
PIASubdomainUSSeattle string = "us-seattle" models.PIARegion("US New York City"): "us-newyorkcity",
PIASubdomainUSSiliconValley string = "us-siliconvalley" models.PIARegion("US Seattle"): "us-seattle",
PIASubdomainUSTexas string = "us-texas" models.PIARegion("US Silicon Valley"): "us-siliconvalley",
PIASubdomainUSWashingtonDC string = "us-washingtondc" models.PIARegion("US Texas"): "us-texas",
PIASubdomainUSWest string = "us-west" models.PIARegion("US Washington DC"): "us-washingtondc",
) models.PIARegion("US West"): "us-west",
}
var PIARegionToSubdomainMapping = map[models.PIARegion]string{ subdomain, ok := mapping[region]
AUMelbourne: PIASubdomainAUMelbourne, if !ok {
AUPerth: PIASubdomainAUPerth, return "", fmt.Errorf("PIA region %q does not exist and can only be one of ", strings.Join(PIAGeoChoices(), ","))
AUSydney: PIASubdomainAUSydney, }
Austria: PIASubdomainAustria, return subdomain, nil
Belgium: PIASubdomainBelgium,
CAMontreal: PIASubdomainCAMontreal,
CAToronto: PIASubdomainCAToronto,
CAVancouver: PIASubdomainCAVancouver,
CzechRepublic: PIASubdomainCzechRepublic,
DEBerlin: PIASubdomainDEBerlin,
DEFrankfurt: PIASubdomainDEFrankfurt,
Denmark: PIASubdomainDenmark,
Finland: PIASubdomainFinland,
France: PIASubdomainFrance,
HongKong: PIASubdomainHongKong,
Hungary: PIASubdomainHungary,
India: PIASubdomainIndia,
Ireland: PIASubdomainIreland,
Israel: PIASubdomainIsrael,
Italy: PIASubdomainItaly,
Japan: PIASubdomainJapan,
Luxembourg: PIASubdomainLuxembourg,
Mexico: PIASubdomainMexico,
Netherlands: PIASubdomainNetherlands,
NewZealand: PIASubdomainNewZealand,
Norway: PIASubdomainNorway,
Poland: PIASubdomainPoland,
Romania: PIASubdomainRomania,
Singapore: PIASubdomainSingapore,
Spain: PIASubdomainSpain,
Sweden: PIASubdomainSweden,
Switzerland: PIASubdomainSwitzerland,
UAE: PIASubdomainUAE,
UKLondon: PIASubdomainUKLondon,
UKManchester: PIASubdomainUKManchester,
UKSouthampton: PIASubdomainUKSouthampton,
USAtlanta: PIASubdomainUSAtlanta,
USCalifornia: PIASubdomainUSCalifornia,
USChicago: PIASubdomainUSChicago,
USDenver: PIASubdomainUSDenver,
USEast: PIASubdomainUSEast,
USFlorida: PIASubdomainUSFlorida,
USHouston: PIASubdomainUSHouston,
USLasVegas: PIASubdomainUSLasVegas,
USNewYorkCity: PIASubdomainUSNewYorkCity,
USSeattle: PIASubdomainUSSeattle,
USSiliconValley: PIASubdomainUSSiliconValley,
USTexas: PIASubdomainUSTexas,
USWashingtonDC: PIASubdomainUSWashingtonDC,
USWest: PIASubdomainUSWest,
} }
const ( const (

View File

@@ -9,7 +9,7 @@ type (
DNSHost string DNSHost string
// PIAEncryption defines the level of encryption for communication with PIA servers // PIAEncryption defines the level of encryption for communication with PIA servers
PIAEncryption string PIAEncryption string
// PIARegion contains the list of regions available for PIA // PIARegion is used to define the list of regions available for PIA
PIARegion string PIARegion string
// URL is an HTTP(s) URL address // URL is an HTTP(s) URL address
URL string URL string

View File

@@ -76,9 +76,7 @@ func (p *paramsReader) GetPIAEncryption() (models.PIAEncryption, error) {
// GetPIARegion obtains the region for the PIA server from the // GetPIARegion obtains the region for the PIA server from the
// environment variable REGION // environment variable REGION
func (p *paramsReader) GetPIARegion() (region models.PIARegion, err error) { func (p *paramsReader) GetPIARegion() (region models.PIARegion, err error) {
choices := []string{ choices := constants.PIAGeoChoices()
string(constants.AUMelbourne), string(constants.AUPerth), string(constants.AUSydney), string(constants.Austria), string(constants.Belgium), string(constants.CAMontreal), string(constants.CAToronto), string(constants.CAVancouver), string(constants.CzechRepublic), string(constants.DEBerlin), string(constants.DEFrankfurt), string(constants.Denmark), string(constants.Finland), string(constants.France), string(constants.HongKong), string(constants.Hungary), string(constants.India), string(constants.Ireland), string(constants.Israel), string(constants.Italy), string(constants.Japan), string(constants.Luxembourg), string(constants.Mexico), string(constants.Netherlands), string(constants.NewZealand), string(constants.Norway), string(constants.Poland), string(constants.Romania), string(constants.Singapore), string(constants.Spain), string(constants.Sweden), string(constants.Switzerland), string(constants.UAE), string(constants.UKLondon), string(constants.UKManchester), string(constants.UKSouthampton), string(constants.USAtlanta), string(constants.USCalifornia), string(constants.USChicago), string(constants.USDenver), string(constants.USEast), string(constants.USFlorida), string(constants.USHouston), string(constants.USLasVegas), string(constants.USNewYorkCity), string(constants.USSeattle), string(constants.USSiliconValley), string(constants.USTexas), string(constants.USWashingtonDC), string(constants.USWest),
}
s, err := p.envParams.GetValueIfInside("REGION", choices) s, err := p.envParams.GetValueIfInside("REGION", choices)
if len(s) == 0 { // Suggestion by @rorph https://github.com/rorph if len(s) == 0 { // Suggestion by @rorph https://github.com/rorph
s = choices[rand.Int()%len(choices)] s = choices[rand.Int()%len(choices)]

View File

@@ -34,7 +34,10 @@ func (c *configurator) BuildConf(region models.PIARegion, protocol models.Networ
port = 501 port = 501
} }
} }
subdomain := constants.PIARegionToSubdomainMapping[region] subdomain, err := constants.PIAGeoToSubdomainMapping(region)
if err != nil {
return nil, 0, err
}
IPs, err = c.lookupIP(subdomain + ".privateinternetaccess.com") IPs, err = c.lookupIP(subdomain + ".privateinternetaccess.com")
if err != nil { if err != nil {
return nil, 0, err return nil, 0, err
@@ -56,6 +59,7 @@ func (c *configurator) BuildConf(region models.PIARegion, protocol models.Networ
"pull-filter ignore \"auth-token\"", // prevent auth failed loops "pull-filter ignore \"auth-token\"", // prevent auth failed loops
"auth-retry nointeract", "auth-retry nointeract",
"disable-occ", "disable-occ",
"remote-random",
// Modified variables // Modified variables
fmt.Sprintf("auth-user-pass %s", constants.OpenVPNAuthConf), fmt.Sprintf("auth-user-pass %s", constants.OpenVPNAuthConf),