Add the ProtonVPN server networks and addresses to the IP lookup (closes #236)
check / check (push) Successful in 1m27s
check / check (push) Successful in 1m27s
Adds the VPN lists `protonvpn`, the servers' /24 networks, IPv4 only, and `protonvpn_entry`, the servers' IPv4 and IPv6 addresses. Each is downloaded once a day and shows in `flags.is_vpn` and `vpn_providers` with no other change. Proton's `/vpn/logicals` answers 401 without a logged-in session, even with a current client's `x-pm-appversion`, so both come from the public ProtonVPN-IPs mirror. No request header is needed. Judgement call: the mirror's /24 file as well as its exact addresses. Its README says traffic leaves from unpublished addresses in those networks. The cost is that neighbouring addresses are listed too. Model: opus-5-5
This commit is contained in:
1 parent
641798bb22
commit
c149de1d9a
6 files changed
+114
-1
No files matched your search
@@ -70,6 +70,19 @@ const (
|
||||
"config":{"api":{"ips":["192.0.2.73"]}}}`
|
||||
)
|
||||
|
||||
// protonVPNBody is a small file in the format of the ProtonVPN-IPs list.
|
||||
const protonVPNBody = "#\n# protonvpn_ip_ranges.txt\n" +
|
||||
"# https://github.com/tn3w/ProtonVPN-IPs\n#\n" +
|
||||
"# The /24 block of every advertised IPv4.\n#\n" +
|
||||
"192.0.2.0/24\n198.51.100.0/24\n"
|
||||
|
||||
// protonVPNEntryBody is a small file in the format of the ProtonVPN-IPs list
|
||||
// of server addresses.
|
||||
const protonVPNEntryBody = "#\n# protonvpn_entry_ips.txt\n" +
|
||||
"# https://github.com/tn3w/ProtonVPN-IPs\n#\n" +
|
||||
"# Entry IPs clients connect to, resolved from ProtonVPN hostnames.\n#\n" +
|
||||
"192.0.2.80\n2001:db8::80\n"
|
||||
|
||||
// errorPage is a file that is no list, as a publisher's error page is.
|
||||
const errorPage = "<!DOCTYPE html>\n<html></html>\n"
|
||||
|
||||
@@ -267,6 +280,20 @@ func TestLookupFindsVPNServers(t *testing.T) {
|
||||
listed: []string{"192.0.2.70", "192.0.2.71", "192.0.2.72"},
|
||||
unlisted: []string{"192.0.2.73", "2001:db8::70"},
|
||||
},
|
||||
{
|
||||
name: "ProtonVPN networks",
|
||||
format: FormatProtonVPN,
|
||||
body: protonVPNBody,
|
||||
listed: []string{"192.0.2.0", "192.0.2.255", "198.51.100.7"},
|
||||
unlisted: []string{"192.0.3.1", "2001:db8::90"},
|
||||
},
|
||||
{
|
||||
name: "ProtonVPN server addresses",
|
||||
format: FormatProtonVPN,
|
||||
body: protonVPNEntryBody,
|
||||
listed: []string{"192.0.2.80", "2001:db8::80"},
|
||||
unlisted: []string{"192.0.2.81", "2001:db8::81"},
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -479,6 +506,31 @@ func TestWrongVPNDocumentFailsToParse(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestWrongProtonVPNDocumentFailsToParse parses documents that are not a
|
||||
// ProtonVPN-IPs list. Each fails, so none can replace a good copy.
|
||||
func TestWrongProtonVPNDocumentFailsToParse(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
bodies := map[string]string{
|
||||
"error page": errorPage,
|
||||
"JSON": `{"status":"ok"}`,
|
||||
"comments only": "#\n# protonvpn_ip_ranges.txt\n#\n",
|
||||
"bad network": "192.0.2.0/24\nexample\n",
|
||||
"an empty file": "",
|
||||
}
|
||||
|
||||
for name, body := range bodies {
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
addresses, err := parse(strings.NewReader(body), FormatProtonVPN)
|
||||
if err == nil {
|
||||
t.Errorf("parse returned %v and no error", addresses.Ranges())
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestLookupMarksVPNLists looks up an address on a VPN list and on another
|
||||
// list. Only the VPN list's listing says it is one.
|
||||
func TestLookupMarksVPNLists(t *testing.T) {
|
||||
@@ -523,7 +575,10 @@ func TestPublicListsMarkTheVPNLists(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
want := []string{"ivpn", "mullvad", "nordvpn", "pia", "x4bnet", "x4bnet_v6"}
|
||||
want := []string{
|
||||
"ivpn", "mullvad", "nordvpn", "pia", "protonvpn", "protonvpn_entry",
|
||||
"x4bnet", "x4bnet_v6",
|
||||
}
|
||||
if !slices.Equal(got, want) {
|
||||
t.Errorf("VPN lists %v, want %v", got, want)
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user