Skip to content

Commit 88ad10d

Browse files
committedMay 1, 2020
PIA and Windscribe hardcoded IP addresses
- Allows to not need to resolve subdomains at start before tunneling - Allows for Unbound to be configured and started after tunneling - Refers to #127
·
v3.40.0v3.0.0
1 parent f4cd189 commit 88ad10d

File tree

7 files changed

+538
-231
lines changed

7 files changed

+538
-231
lines changed
 

‎internal/constants/lookup_test.go

Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
package constants
2+
3+
import (
4+
"fmt"
5+
"net"
6+
"strings"
7+
"testing"
8+
)
9+
10+
func Test_LookupPIAServers(t *testing.T) {
11+
t.SkipNow()
12+
subdomains := []string{
13+
"au-melbourne",
14+
"au-perth",
15+
"au-sydney",
16+
"austria",
17+
"belgium",
18+
"ca-montreal",
19+
"ca-toronto",
20+
"ca-vancouver",
21+
"czech",
22+
"de-berlin",
23+
"de-frankfurt",
24+
"denmark",
25+
"fi",
26+
"france",
27+
"hk",
28+
"hungary",
29+
"in",
30+
"ireland",
31+
"israel",
32+
"italy",
33+
"japan",
34+
"lu",
35+
"mexico",
36+
"nl",
37+
"nz",
38+
"no",
39+
"poland",
40+
"ro",
41+
"sg",
42+
"spain",
43+
"sweden",
44+
"swiss",
45+
"ae",
46+
"uk-london",
47+
"uk-manchester",
48+
"uk-southampton",
49+
"us-atlanta",
50+
"us-california",
51+
"us-chicago",
52+
"us-denver",
53+
"us-east",
54+
"us-florida",
55+
"us-houston",
56+
"us-lasvegas",
57+
"us-newyorkcity",
58+
"us-seattle",
59+
"us-siliconvalley",
60+
"us-texas",
61+
"us-washingtondc",
62+
"us-west",
63+
}
64+
for _, subdomain := range subdomains {
65+
ips, err := net.LookupIP(subdomain + ".privateinternetaccess.com")
66+
if err != nil {
67+
t.Log(err)
68+
continue
69+
}
70+
s := make([]string, len(ips))
71+
for i := range ips {
72+
s[i] = fmt.Sprintf("{%s}", strings.ReplaceAll(ips[i].String(), ".", ", "))
73+
}
74+
t.Logf("%s: %s", subdomain, strings.Join(s, ", "))
75+
}
76+
}
77+
78+
func Test_LookupWindscribeServers(t *testing.T) {
79+
t.SkipNow()
80+
subdomains := []string{
81+
"al",
82+
"ar",
83+
"ar",
84+
"au",
85+
"at",
86+
"az",
87+
"be",
88+
"ba",
89+
"br",
90+
"bg",
91+
"ca",
92+
"ca-west",
93+
"co",
94+
"hr",
95+
"cy",
96+
"cz",
97+
"dk",
98+
"ee",
99+
"aq",
100+
"fi",
101+
"fr",
102+
"ge",
103+
"de",
104+
"gr",
105+
"hk",
106+
"hu",
107+
"is",
108+
"in",
109+
"id",
110+
"ie",
111+
"il",
112+
"it",
113+
"jp",
114+
"lv",
115+
"lt",
116+
"mk",
117+
"my",
118+
"mx",
119+
"md",
120+
"nl",
121+
"nz",
122+
"no",
123+
"ph",
124+
"pl",
125+
"pt",
126+
"ro",
127+
"ru",
128+
"rs",
129+
"sg",
130+
"sk",
131+
"si",
132+
"za",
133+
"kr",
134+
"es",
135+
"se",
136+
"ch",
137+
"th",
138+
"tn",
139+
"tr",
140+
"ua",
141+
"ae",
142+
"uk",
143+
"us-central",
144+
"us-east",
145+
"us-west",
146+
"vn",
147+
"wf-ca",
148+
"wf-jp",
149+
"wf-uk",
150+
"wf-us",
151+
}
152+
for _, subdomain := range subdomains {
153+
ips, err := net.LookupIP(subdomain + ".windscribe.com")
154+
if err != nil {
155+
t.Log(err)
156+
continue
157+
}
158+
s := make([]string, len(ips))
159+
for i := range ips {
160+
s[i] = fmt.Sprintf("{%s}", strings.ReplaceAll(ips[i].String(), ".", ", "))
161+
}
162+
t.Logf("%s: %s", subdomain, strings.Join(s, ", "))
163+
}
164+
}

‎internal/constants/pia.go

Lines changed: 206 additions & 54 deletions
Large diffs are not rendered by default.

‎internal/constants/windscribe.go

Lines changed: 143 additions & 149 deletions
Large diffs are not rendered by default.

‎internal/models/pia.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package models
2+
3+
import "net"
4+
5+
type PIAServer struct {
6+
IPs []net.IP
7+
Region PIARegion
8+
}

‎internal/models/windscribe.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package models
22

3+
import "net"
4+
35
type WindscribeServer struct {
4-
Region WindscribeRegion
5-
Subdomain string
6+
Region WindscribeRegion
7+
IPs []net.IP
68
}

‎internal/pia/conf.go

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,14 @@ import (
1111
)
1212

1313
func (c *configurator) GetOpenVPNConnections(region models.PIARegion, protocol models.NetworkProtocol, encryption models.PIAEncryption, targetIP net.IP) (connections []models.OpenVPNConnection, err error) {
14-
geoMapping := constants.PIAGeoToSubdomainMapping()
15-
var subdomain string
16-
for r, s := range geoMapping {
17-
if strings.EqualFold(string(region), string(r)) {
18-
subdomain = s
19-
break
14+
var IPs []net.IP
15+
for _, server := range constants.PIAServers() {
16+
if strings.EqualFold(string(server.Region), string(region)) {
17+
IPs = server.IPs
2018
}
2119
}
22-
if len(subdomain) == 0 {
23-
return nil, fmt.Errorf("region %q has no associated PIA subdomain", region)
24-
}
25-
hostname := subdomain + ".privateinternetaccess.com"
26-
IPs, err := c.lookupIP(hostname)
27-
if err != nil {
28-
return nil, err
20+
if len(IPs) == 0 {
21+
return nil, fmt.Errorf("no IP found for region %q", region)
2922
}
3023
if targetIP != nil {
3124
found := false
@@ -36,7 +29,7 @@ func (c *configurator) GetOpenVPNConnections(region models.PIARegion, protocol m
3629
}
3730
}
3831
if !found {
39-
return nil, fmt.Errorf("target IP address %q not found from IP addresses resolved from %s", targetIP, hostname)
32+
return nil, fmt.Errorf("target IP address %q not found in IP addresses", targetIP)
4033
}
4134
IPs = []net.IP{targetIP}
4235
}

‎internal/windscribe/conf.go

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,20 +11,14 @@ import (
1111
)
1212

1313
func (c *configurator) GetOpenVPNConnections(region models.WindscribeRegion, protocol models.NetworkProtocol, customPort uint16, targetIP net.IP) (connections []models.OpenVPNConnection, err error) {
14-
var subdomain string
14+
var IPs []net.IP
1515
for _, server := range constants.WindscribeServers() {
16-
if server.Region == region {
17-
subdomain = server.Subdomain
18-
break
16+
if strings.EqualFold(string(server.Region), string(region)) {
17+
IPs = server.IPs
1918
}
2019
}
21-
if len(subdomain) == 0 {
22-
return nil, fmt.Errorf("no server found for region %q", region)
23-
}
24-
hostname := subdomain + ".windscribe.com"
25-
IPs, err := c.lookupIP(hostname)
26-
if err != nil {
27-
return nil, err
20+
if len(IPs) == 0 {
21+
return nil, fmt.Errorf("no IP found for region %q", region)
2822
}
2923
if targetIP != nil {
3024
found := false
@@ -35,7 +29,7 @@ func (c *configurator) GetOpenVPNConnections(region models.WindscribeRegion, pro
3529
}
3630
}
3731
if !found {
38-
return nil, fmt.Errorf("target IP address %q not found from IP addresses resolved from %s", targetIP, hostname)
32+
return nil, fmt.Errorf("target IP address %q not found in IP addresses", targetIP)
3933
}
4034
IPs = []net.IP{targetIP}
4135
}

0 commit comments

Comments
 (0)
Please sign in to comment.