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:
@@ -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))
|
||||
}
|
||||
|
||||
|
||||
@@ -7,18 +7,18 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_PIAServer_String(t *testing.T) {
|
||||
func Test_PIAOldServer_String(t *testing.T) {
|
||||
t.Parallel()
|
||||
testCases := map[string]struct {
|
||||
server PIAServer
|
||||
server PIAOldServer
|
||||
s string
|
||||
}{
|
||||
"no ips": {
|
||||
server: PIAServer{Region: "a b"},
|
||||
server: PIAOldServer{Region: "a b"},
|
||||
s: `{Region: "a b", IPs: []net.IP{}}`,
|
||||
},
|
||||
"with ips": {
|
||||
server: PIAServer{Region: "a b", IPs: []net.IP{{1, 1, 1, 1}, {2, 2, 2, 2}}},
|
||||
server: PIAOldServer{Region: "a b", IPs: []net.IP{{1, 1, 1, 1}, {2, 2, 2, 2}}},
|
||||
s: `{Region: "a b", IPs: []net.IP{{1, 1, 1, 1}, {2, 2, 2, 2}}}`,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@ type AllServers struct {
|
||||
Cyberghost CyberghostServers `json:"cyberghost"`
|
||||
Mullvad MullvadServers `json:"mullvad"`
|
||||
Nordvpn NordvpnServers `json:"nordvpn"`
|
||||
PiaOld PiaServers `json:"piaOld"`
|
||||
PiaOld PiaOldServers `json:"piaOld"`
|
||||
Pia PiaServers `json:"pia"`
|
||||
Purevpn PurevpnServers `json:"purevpn"`
|
||||
Surfshark SurfsharkServers `json:"surfshark"`
|
||||
@@ -28,6 +28,11 @@ type NordvpnServers struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []NordvpnServer `json:"servers"`
|
||||
}
|
||||
type PiaOldServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []PIAOldServer `json:"servers"`
|
||||
}
|
||||
type PiaServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
|
||||
Reference in New Issue
Block a user