Add multi hop regions and ips for Surfshark
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
"sort"
|
||||
@@ -23,36 +24,34 @@ func _main() int {
|
||||
provider := flag.String("provider", "surfshark", "VPN provider to parse openvpn files for, can be 'surfshark'")
|
||||
flag.Parse()
|
||||
|
||||
var url string
|
||||
var urls []string
|
||||
var suffix string
|
||||
switch *provider {
|
||||
case "surfshark":
|
||||
url = "https://account.surfshark.com/api/v1/server/configurations"
|
||||
urls = []string{
|
||||
"https://account.surfshark.com/api/v1/server/configurations",
|
||||
"https://v2uploads.zopim.io/p/2/L/p2LbwLkvfQoSdzOl6VEltzQA6StiZqrs/12500634259669c77012765139bcfe4f4c90db1e.zip",
|
||||
}
|
||||
suffix = ".prod.surfshark.com"
|
||||
default:
|
||||
fmt.Printf("Provider %q is not supported\n", *provider)
|
||||
return 1
|
||||
}
|
||||
client := network.NewClient(time.Second)
|
||||
zipBytes, status, err := client.GetContent(url)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 1
|
||||
} else if status != http.StatusOK {
|
||||
fmt.Printf("Getting %s results in HTTP status code %d\n", url, status)
|
||||
return 1
|
||||
}
|
||||
contents, err := zipExtractAll(zipBytes)
|
||||
contents, err := fetchAndExtractFiles(urls...)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 1
|
||||
}
|
||||
|
||||
uniqueSubdomains := make(map[string]struct{})
|
||||
for _, content := range contents {
|
||||
subdomain, err := extractInformation(content)
|
||||
subdomain, err := extractInformation(content, suffix)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return 1
|
||||
} else if len(subdomain) > 0 {
|
||||
uniqueSubdomains[subdomain] = struct{}{}
|
||||
}
|
||||
uniqueSubdomains[subdomain] = struct{}{}
|
||||
}
|
||||
subdomains := make([]string, len(uniqueSubdomains))
|
||||
i := 0
|
||||
@@ -67,6 +66,24 @@ func _main() int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func fetchAndExtractFiles(urls ...string) (contents [][]byte, err error) {
|
||||
client := network.NewClient(10 * time.Second)
|
||||
for _, url := range urls {
|
||||
zipBytes, status, err := client.GetContent(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
} else if status != http.StatusOK {
|
||||
return nil, fmt.Errorf("Getting %s results in HTTP status code %d", url, status)
|
||||
}
|
||||
newContents, err := zipExtractAll(zipBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
contents = append(contents, newContents...)
|
||||
}
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func zipExtractAll(zipBytes []byte) (contents [][]byte, err error) {
|
||||
r, err := zip.NewReader(bytes.NewReader(zipBytes), int64(len(zipBytes)))
|
||||
if err != nil {
|
||||
@@ -90,7 +107,7 @@ func zipExtractAll(zipBytes []byte) (contents [][]byte, err error) {
|
||||
return contents, nil
|
||||
}
|
||||
|
||||
func extractInformation(content []byte) (subdomain string, err error) {
|
||||
func extractInformation(content []byte, suffix string) (subdomain string, err error) {
|
||||
lines := strings.Split(string(content), "\n")
|
||||
for _, line := range lines {
|
||||
if strings.HasPrefix(line, "remote ") {
|
||||
@@ -99,7 +116,10 @@ func extractInformation(content []byte) (subdomain string, err error) {
|
||||
return "", fmt.Errorf("not enough words on line %q", line)
|
||||
}
|
||||
host := words[1]
|
||||
return strings.TrimSuffix(host, ".prod.surfshark.com"), nil
|
||||
if net.ParseIP(host) != nil {
|
||||
return "", nil // ignore IP addresses
|
||||
}
|
||||
return strings.TrimSuffix(host, suffix), nil
|
||||
}
|
||||
}
|
||||
return "", fmt.Errorf("could not find remote line")
|
||||
|
||||
@@ -321,6 +321,7 @@ func surfsharkServers() []server {
|
||||
{subdomain: "au-mel", region: "Australia Melbourne"},
|
||||
{subdomain: "au-per", region: "Australia Perth"},
|
||||
{subdomain: "au-syd", region: "Australia Sydney"},
|
||||
{subdomain: "au-us", region: "Australia US"},
|
||||
{subdomain: "az-bak", region: "Azerbaijan"},
|
||||
{subdomain: "ba-sjj", region: "Bosnia and Herzegovina "},
|
||||
{subdomain: "be-bru", region: "Belgium"},
|
||||
@@ -328,6 +329,7 @@ func surfsharkServers() []server {
|
||||
{subdomain: "br-sao", region: "Brazil"},
|
||||
{subdomain: "ca-mon", region: "Canada Montreal"},
|
||||
{subdomain: "ca-tor", region: "Canada Toronto"},
|
||||
{subdomain: "ca-us", region: "Canada US"},
|
||||
{subdomain: "ca-van", region: "Canada Vancouver"},
|
||||
{subdomain: "ch-zur", region: "Switzerland"},
|
||||
{subdomain: "cl-san", region: "Chile"},
|
||||
@@ -342,6 +344,8 @@ func surfsharkServers() []server {
|
||||
{subdomain: "de-fra-st003", region: "Germany Frankfurt am Main st003"},
|
||||
{subdomain: "de-muc", region: "Germany Munich"},
|
||||
{subdomain: "de-nue", region: "Germany Nuremberg"},
|
||||
{subdomain: "de-sg", region: "Germany Singapour"},
|
||||
{subdomain: "de-uk", region: "Germany UK"},
|
||||
{subdomain: "dk-cph", region: "Denmark"},
|
||||
{subdomain: "ee-tll", region: "Estonia"},
|
||||
{subdomain: "es-bcn", region: "Spain Barcelona"},
|
||||
@@ -351,6 +355,7 @@ func surfsharkServers() []server {
|
||||
{subdomain: "fr-bod", region: "France Bordeaux"},
|
||||
{subdomain: "fr-mrs", region: "France Marseilles"},
|
||||
{subdomain: "fr-par", region: "France Paris"},
|
||||
{subdomain: "fr-se", region: "France Sweden"},
|
||||
{subdomain: "gr-ath", region: "Greece"},
|
||||
{subdomain: "hk-hkg", region: "Hong Kong"},
|
||||
{subdomain: "hr-zag", region: "Croatia"},
|
||||
@@ -361,6 +366,7 @@ func surfsharkServers() []server {
|
||||
{subdomain: "in-chn", region: "India Chennai"},
|
||||
{subdomain: "in-idr", region: "India Indore"},
|
||||
{subdomain: "in-mum", region: "India Mumbai"},
|
||||
{subdomain: "in-uk", region: "India UK"},
|
||||
{subdomain: "is-rkv", region: "Iceland"},
|
||||
{subdomain: "it-mil", region: "Italy Milan"},
|
||||
{subdomain: "it-rom", region: "italy Rome"},
|
||||
@@ -383,6 +389,7 @@ func surfsharkServers() []server {
|
||||
{subdomain: "ng-lag", region: "Nigeria"},
|
||||
{subdomain: "nl-ams", region: "Netherlands Amsterdam"},
|
||||
{subdomain: "nl-ams-st001", region: "Netherlands Amsterdam st001"},
|
||||
{subdomain: "nl-us", region: "Netherlands US"},
|
||||
{subdomain: "no-osl", region: "Norway"},
|
||||
{subdomain: "nz-akl", region: "New Zealand"},
|
||||
{subdomain: "ph-mnl", region: "Philippines"},
|
||||
@@ -397,6 +404,8 @@ func surfsharkServers() []server {
|
||||
{subdomain: "ru-mos", region: "Russia Moscow"},
|
||||
{subdomain: "ru-spt", region: "Russia St. Petersburg"},
|
||||
{subdomain: "se-sto", region: "Sweden"},
|
||||
{subdomain: "sg-hk", region: "Singapore Hong Kong"},
|
||||
{subdomain: "sg-nl", region: "Singapore Netherlands"},
|
||||
{subdomain: "sg-sng", region: "Singapore"},
|
||||
{subdomain: "sg-sng-st001", region: "Singapore st001"},
|
||||
{subdomain: "sg-sng-st002", region: "Singapore st002"},
|
||||
@@ -408,6 +417,8 @@ func surfsharkServers() []server {
|
||||
{subdomain: "tr-bur", region: "Turkey"},
|
||||
{subdomain: "tw-tai", region: "Taiwan"},
|
||||
{subdomain: "ua-iev", region: "Ukraine"},
|
||||
{subdomain: "uk-de", region: "UK Germany"},
|
||||
{subdomain: "uk-fr", region: "UK France"},
|
||||
{subdomain: "uk-gla", region: "UK Glasgow"},
|
||||
{subdomain: "uk-lon", region: "UK London"},
|
||||
{subdomain: "uk-lon-st001", region: "UK London st001"},
|
||||
@@ -432,6 +443,7 @@ func surfsharkServers() []server {
|
||||
{subdomain: "us-ltm", region: "US Latham"},
|
||||
{subdomain: "us-mia", region: "US Miami"},
|
||||
{subdomain: "us-mnz", region: "US Maryland"},
|
||||
{subdomain: "us-nl", region: "US Netherlands"},
|
||||
{subdomain: "us-nyc", region: "US New York City"},
|
||||
{subdomain: "us-nyc-mp001", region: "US New York City mp001"},
|
||||
{subdomain: "us-nyc-st001", region: "US New York City st001"},
|
||||
@@ -441,6 +453,7 @@ func surfsharkServers() []server {
|
||||
{subdomain: "us-nyc-st005", region: "US New York City st005"},
|
||||
{subdomain: "us-orl", region: "US Orlando"},
|
||||
{subdomain: "us-phx", region: "US Phoenix"},
|
||||
{subdomain: "us-pt", region: "US Portugal"},
|
||||
{subdomain: "us-sea", region: "US Seatle"},
|
||||
{subdomain: "us-sfo", region: "US San Francisco"},
|
||||
{subdomain: "us-slc", region: "US Salt Lake City"},
|
||||
|
||||
Reference in New Issue
Block a user