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
This commit is contained in:
28
internal/updater/openvpn.go
Normal file
28
internal/updater/openvpn.go
Normal file
@@ -0,0 +1,28 @@
|
||||
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
|
||||
}
|
||||
Reference in New Issue
Block a user