Files
gluetun/internal/updater/openvpn.go
Quentin McGaw d463e4cb69 New PIA servers support (#227)
* Adapt storage: SyncServers write to file option, export FlushToFile
* CLI built-in updater for old and new PIA servers
* Update hardcoded IP addresses for PIA old and new servers
* Add PIA old to allServers struct and update timestamps
* Adapt code to work with new and old PIA servers
* Remove PIA subdomains (unneeded) from resolver tool
2020-08-28 08:17:04 -04:00

29 lines
592 B
Go

package updater
import (
"net"
"strings"
)
func extractRemoteLinesFromOpenvpn(content []byte) (remoteLines []string) {
lines := strings.Split(string(content), "\n")
for _, line := range lines {
if strings.HasPrefix(line, "remote ") {
remoteLines = append(remoteLines, line)
}
}
return remoteLines
}
func extractIPsFromRemoteLines(remoteLines []string) (ips []net.IP) {
for _, remoteLine := range remoteLines {
fields := strings.Fields(remoteLine)
ip := net.ParseIP(fields[1])
if ip == nil { // not an IP address
continue
}
ips = append(ips, ip)
}
return ips
}