save wip
This commit is contained in:
71
vpnlist.go
Normal file
71
vpnlist.go
Normal file
@@ -0,0 +1,71 @@
|
||||
package main
|
||||
|
||||
// get https://www.expressvpn.com/vpn-server
|
||||
// remove everyting starting with >
|
||||
// remove until "Not supported" and after What the green checks mean
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"net"
|
||||
"net/http"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
func getServerList(url string) []string {
|
||||
ret := []string{}
|
||||
// Create HTTP client with timeout
|
||||
client := &http.Client{
|
||||
Timeout: 30 * time.Second,
|
||||
}
|
||||
|
||||
// Make request
|
||||
response, err := client.Get(url)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return nil
|
||||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
buf := bufio.NewReader(bufio.NewReader(response.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
|
||||
}
|
||||
|
||||
// france-paris-1-ca-version-2.expressnetw.com
|
||||
line = strings.ToLower(line)
|
||||
line = strings.ReplaceAll(line, " & ", "")
|
||||
line = strings.ReplaceAll(line, " ", "")
|
||||
|
||||
name := fmt.Sprintf("%s-ca-version-2.expressnetw.com", line)
|
||||
fmt.Println(name)
|
||||
|
||||
if _, err := net.ResolveIPAddr("ip4", name); err == nil {
|
||||
ret = append(ret, name)
|
||||
}
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
Reference in New Issue
Block a user