Feature: filter by hostname for Mullvad servers

This commit is contained in:
Quentin McGaw
2021-05-08 19:17:36 +00:00
parent a34769ae02
commit 2ec2f45c82
11 changed files with 382 additions and 143 deletions

View File

@@ -48,17 +48,18 @@ func (s *HideMyAssServer) String() string {
}
type MullvadServer struct {
IPs []net.IP `json:"ips"`
IPsV6 []net.IP `json:"ipsv6"`
Country string `json:"country"`
City string `json:"city"`
ISP string `json:"isp"`
Owned bool `json:"owned"`
IPs []net.IP `json:"ips"`
IPsV6 []net.IP `json:"ipsv6"`
Country string `json:"country"`
City string `json:"city"`
Hostname string `json:"hostname"`
ISP string `json:"isp"`
Owned bool `json:"owned"`
}
func (s *MullvadServer) String() string {
return fmt.Sprintf("{Country: %q, City: %q, ISP: %q, Owned: %t, IPs: %s, IPsV6: %s}",
s.Country, s.City, s.ISP, s.Owned, goStringifyIPs(s.IPs), goStringifyIPs(s.IPsV6))
return fmt.Sprintf("{Country: %q, City: %q, Hostname: %q, ISP: %q, Owned: %t, IPs: %s, IPsV6: %s}",
s.Country, s.City, s.Hostname, s.ISP, s.Owned, goStringifyIPs(s.IPs), goStringifyIPs(s.IPsV6))
}
type NordvpnServer struct { //nolint:maligned

View File

@@ -15,15 +15,16 @@ func Test_MullvadServer_String(t *testing.T) {
}{
"example": {
server: MullvadServer{
IPs: []net.IP{{1, 1, 1, 1}},
IPsV6: []net.IP{{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x1}},
Country: "That Country",
City: "That City",
ISP: "not spying on you",
Owned: true,
IPs: []net.IP{{1, 1, 1, 1}},
IPsV6: []net.IP{{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x1}},
Country: "That Country",
City: "That City",
Hostname: "hostname",
ISP: "not spying on you",
Owned: true,
},
//nolint:lll
s: `{Country: "That Country", City: "That City", ISP: "not spying on you", Owned: true, IPs: []net.IP{{1, 1, 1, 1}}, IPsV6: []net.IP{{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x1}}}`,
s: `{Country: "That Country", City: "That City", Hostname: "hostname", ISP: "not spying on you", Owned: true, IPs: []net.IP{{1, 1, 1, 1}}, IPsV6: []net.IP{{0x20, 0x1, 0xd, 0xb8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2, 0x0, 0x1}}}`,
},
}
for name, testCase := range testCases {