start dailymotion support, improve vendor support

This commit is contained in:
Xavier Henner
2019-08-17 20:11:00 +02:00
parent 1926c3bcd6
commit a1ce8b794b
7 changed files with 66 additions and 29 deletions

View File

@@ -18,10 +18,10 @@ import (
type ExpressVPN struct {
}
func (s *ExpressVPN) ServerList() (error, *[]string) {
func (s *ExpressVPN) ServerList() (error, *map[string]string) {
var mux sync.Mutex
requestCount := 0
VPNNames := map[string]bool{}
VPNNames := map[string]string{}
// Create HTTP client with timeout
client := &http.Client{
@@ -67,14 +67,15 @@ func (s *ExpressVPN) ServerList() (error, *[]string) {
requestCount++
go func(line string) {
conv := "%s-ca-version-2.expressnetw.com"
line = strings.ToLower(line)
line = strings.Replace(line, " & ", "", -1)
line = strings.Replace(line, " ", "", -1)
name := fmt.Sprintf("%s-ca-version-2.expressnetw.com", line)
name := fmt.Sprintf(conv, line)
if _, err := net.ResolveIPAddr("ip4", name); err == nil {
mux.Lock()
VPNNames[name] = true
VPNNames[line] = name
mux.Unlock()
}
requestCount--
@@ -90,11 +91,5 @@ func (s *ExpressVPN) ServerList() (error, *[]string) {
return errors.New("Can't get a list of VPN endpoints"), nil
}
// add the right values
keys := make([]string, 0, len(VPNNames))
for k := range VPNNames {
keys = append(keys, k)
}
return nil, &keys
return nil, &VPNNames
}