static expressvpn list
This commit is contained in:
218
expressvpn.go
218
expressvpn.go
@@ -5,86 +5,174 @@ package main
|
||||
// remove until "Not supported" and after What the green checks mean
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ExpressVPN struct {
|
||||
}
|
||||
|
||||
func (s *ExpressVPN) ServerList() (error, *map[string]string) {
|
||||
var mux sync.Mutex
|
||||
requestCount := 0
|
||||
VPNNames := map[string]string{}
|
||||
|
||||
// Create HTTP client with timeout
|
||||
client := &http.Client{
|
||||
Timeout: 30 * time.Second,
|
||||
names := []string{
|
||||
"Albania",
|
||||
"Algeria",
|
||||
"Andorra",
|
||||
"Argentina",
|
||||
"Armenia",
|
||||
"Australia - Brisbane",
|
||||
"Australia - Melbourne",
|
||||
"Australia - Perth",
|
||||
"Australia - Sydney",
|
||||
"Australia - Sydney - 2",
|
||||
"Austria",
|
||||
"Bangladesh",
|
||||
"Belarus",
|
||||
"Belgium",
|
||||
"Bhutan",
|
||||
"Bosnia and Herzegovina",
|
||||
"Brazil",
|
||||
"Brazil - 2",
|
||||
"Brunei",
|
||||
"Bulgaria",
|
||||
"Cambodia",
|
||||
"Canada - Montreal",
|
||||
"Canada - Toronto",
|
||||
"Canada - Toronto - 2",
|
||||
"Canada - Vancouver",
|
||||
"Chile",
|
||||
"Colombia",
|
||||
"Costa Rica",
|
||||
"Croatia",
|
||||
"Cyprus",
|
||||
"Czech Republic",
|
||||
"Denmark",
|
||||
"Ecuador",
|
||||
"Egypt",
|
||||
"Estonia",
|
||||
"Finland",
|
||||
"France - Paris - 1",
|
||||
"France - Paris - 2",
|
||||
"France - Strasbourg",
|
||||
"Georgia ",
|
||||
"Germany - Frankfurt - 1",
|
||||
"Germany - Frankfurt - 2",
|
||||
"Germany - Frankfurt - 3",
|
||||
"Germany - Nuremberg",
|
||||
"Greece",
|
||||
"Guatemala",
|
||||
"Hong Kong - 1 ",
|
||||
"Hong Kong - 2",
|
||||
"Hong Kong - 4",
|
||||
"Hungary",
|
||||
"Iceland",
|
||||
"India - Chennai",
|
||||
"India - Mumbai - 1",
|
||||
"India (via UK)",
|
||||
"Indonesia",
|
||||
"Ireland",
|
||||
"Isle of Man",
|
||||
"Israel",
|
||||
"Italy - Cosenza",
|
||||
"Italy - Milan",
|
||||
"Japan - Tokyo",
|
||||
"Japan - Tokyo - 2",
|
||||
"Jersey",
|
||||
"Kazakhstan",
|
||||
"Kenya",
|
||||
"Kyrgyzstan",
|
||||
"Laos",
|
||||
"Latvia",
|
||||
"Liechtenstein",
|
||||
"Lithuania",
|
||||
"Luxembourg",
|
||||
"Macau",
|
||||
"Malaysia",
|
||||
"Malta",
|
||||
"Mexico",
|
||||
"Moldova",
|
||||
"Monaco",
|
||||
"Mongolia",
|
||||
"Montenegro",
|
||||
"Myanmar",
|
||||
"Nepal",
|
||||
"Netherlands - Amsterdam",
|
||||
"Netherlands - Amsterdam - 2",
|
||||
"Netherlands - Rotterdam",
|
||||
"Netherlands - The Hague",
|
||||
"New Zealand",
|
||||
"North Macedonia",
|
||||
"Norway",
|
||||
"Pakistan",
|
||||
"Panama",
|
||||
"Peru",
|
||||
"Philippines",
|
||||
"Poland",
|
||||
"Portugal",
|
||||
"Romania",
|
||||
"Serbia",
|
||||
"Singapore - CBD",
|
||||
"Singapore - Jurong",
|
||||
"Singapore - Marina Bay",
|
||||
"Slovakia",
|
||||
"Slovenia",
|
||||
"South Africa",
|
||||
"South Korea - 2",
|
||||
"Spain - Barcelona",
|
||||
"Spain - Barcelona - 2",
|
||||
"Spain - Madrid",
|
||||
"Sri Lanka",
|
||||
"Sweden",
|
||||
"Sweden - 2",
|
||||
"Switzerland",
|
||||
"Switzerland - 2",
|
||||
"Taiwan - 3",
|
||||
"Thailand",
|
||||
"Turkey",
|
||||
"UK - Docklands",
|
||||
"UK - East London",
|
||||
"UK - London",
|
||||
"Ukraine",
|
||||
"Uruguay",
|
||||
"USA - Atlanta",
|
||||
"USA - Chicago",
|
||||
"USA - Dallas",
|
||||
"USA - Dallas - 2",
|
||||
"USA - Denver",
|
||||
"USA - Los Angeles",
|
||||
"USA - Los Angeles - 1",
|
||||
"USA - Los Angeles - 2",
|
||||
"USA - Los Angeles - 3",
|
||||
"USA - Los Angeles - 5 ",
|
||||
"USA - Miami",
|
||||
"USA - Miami - 2",
|
||||
"USA - New Jersey - 1",
|
||||
"USA - New Jersey - 2",
|
||||
"USA - New Jersey - 3",
|
||||
"USA - New York",
|
||||
"USA - New York - 2",
|
||||
"USA - Salt Lake City",
|
||||
"USA - San Francisco",
|
||||
"USA - Seattle",
|
||||
"USA - Tampa - 1",
|
||||
"USA - Washington DC",
|
||||
"Uzbekistan",
|
||||
"Venezuela",
|
||||
"Vietnam",
|
||||
}
|
||||
|
||||
// Make request
|
||||
resp, err := client.Get("https://www.expressvpn.com/vpn-server")
|
||||
if err != nil {
|
||||
return err, nil
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != 200 {
|
||||
return errors.New(fmt.Sprintf("Server List URL is not valid (%d)\n", resp.StatusCode)), nil
|
||||
}
|
||||
|
||||
buf := bufio.NewReader(bufio.NewReader(resp.Body))
|
||||
start := false
|
||||
for {
|
||||
line, err := buf.ReadString('\n')
|
||||
if err != nil {
|
||||
break
|
||||
}
|
||||
line = strings.Trim(line, "\n\r ")
|
||||
if strings.HasPrefix(line, "<") {
|
||||
continue
|
||||
}
|
||||
if line == "Not supported" {
|
||||
start = true
|
||||
continue
|
||||
}
|
||||
if line == "What the green checks mean" {
|
||||
start = false
|
||||
}
|
||||
if !start {
|
||||
continue
|
||||
}
|
||||
|
||||
if line == "" {
|
||||
continue
|
||||
}
|
||||
|
||||
requestCount++
|
||||
go func(line string) {
|
||||
for _, entry := range names {
|
||||
func(entry string) {
|
||||
conv := "%s-ca-version-2.expressnetw.com"
|
||||
line = strings.ToLower(line)
|
||||
line = strings.Replace(line, " & ", "", -1)
|
||||
line = strings.Replace(line, " ", "", -1)
|
||||
entry = strings.ToLower(entry)
|
||||
entry = strings.Replace(entry, " & ", "", -1)
|
||||
entry = strings.Replace(entry, " ", "", -1)
|
||||
|
||||
name := fmt.Sprintf(conv, line)
|
||||
if _, err := net.ResolveIPAddr("ip4", name); err == nil {
|
||||
mux.Lock()
|
||||
VPNNames[line] = name
|
||||
mux.Unlock()
|
||||
}
|
||||
requestCount--
|
||||
}(line)
|
||||
}
|
||||
|
||||
// wait for all resolutions
|
||||
for requestCount > 0 {
|
||||
time.Sleep(100 * time.Millisecond)
|
||||
name := fmt.Sprintf(conv, entry)
|
||||
VPNNames[entry] = name
|
||||
}(entry)
|
||||
}
|
||||
|
||||
if len(VPNNames) == 0 {
|
||||
|
||||
Reference in New Issue
Block a user