Obtain PIA v4 server information from API (#257)

- Obtain CN for port forwarding https verification
- Obtain for each server if they support port forwarding
- Obtain for each server their IP address for openvpn UDP and openvpn TCP (one for each)
- Updater program updated to use API
- Hardcoded values updated for PIA v3 and v4 servers
- Clearer separation between pia v3 and v4
- Fixes #250
This commit is contained in:
Quentin McGaw
2020-10-12 13:57:45 -04:00
committed by GitHub
parent ae7fc5fe96
commit 9f6450502c
13 changed files with 419 additions and 267 deletions

View File

@@ -8,11 +8,32 @@ import (
)
type PIAServer struct {
Region string `json:"region"`
PortForward bool `json:"port_forward"`
OpenvpnUDP PIAServerOpenvpn `json:"openvpn_udp"`
OpenvpnTCP PIAServerOpenvpn `json:"openvpn_tcp"`
}
type PIAServerOpenvpn struct {
IPs []net.IP `json:"ips"`
CN string `json:"cn"`
}
func (p *PIAServerOpenvpn) String() string {
return fmt.Sprintf("models.PIAServerOpenvpn{CN: %q, IPs: %s}", p.CN, goStringifyIPs(p.IPs))
}
func (p *PIAServer) String() string {
return fmt.Sprintf("{Region: %q, PortForward: %t, OpenvpnUDP: %s, OpenvpnTCP: %s}",
p.Region, p.PortForward, p.OpenvpnUDP.String(), p.OpenvpnTCP.String())
}
type PIAOldServer struct {
IPs []net.IP `json:"ips"`
Region string `json:"region"`
}
func (p *PIAServer) String() string {
func (p *PIAOldServer) String() string {
return fmt.Sprintf("{Region: %q, IPs: %s}", p.Region, goStringifyIPs(p.IPs))
}