chore(models): common Server & Servers for all providers (#943)
This commit is contained in:
@@ -28,244 +28,98 @@ func (a AllServers) GetCopy() (servers AllServers) {
|
||||
return servers
|
||||
}
|
||||
|
||||
func (a *AllServers) GetCyberghost() (servers []CyberghostServer) {
|
||||
if a.Cyberghost.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]CyberghostServer, len(a.Cyberghost.Servers))
|
||||
for i, serverToCopy := range a.Cyberghost.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetCyberghost() (servers []Server) {
|
||||
return copyServers(a.Cyberghost.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetExpressvpn() (servers []ExpressvpnServer) {
|
||||
if a.Expressvpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]ExpressvpnServer, len(a.Expressvpn.Servers))
|
||||
for i, serverToCopy := range a.Expressvpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetExpressvpn() (servers []Server) {
|
||||
return copyServers(a.Expressvpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetFastestvpn() (servers []FastestvpnServer) {
|
||||
if a.Fastestvpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]FastestvpnServer, len(a.Fastestvpn.Servers))
|
||||
for i, serverToCopy := range a.Fastestvpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetFastestvpn() (servers []Server) {
|
||||
return copyServers(a.Fastestvpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetHideMyAss() (servers []HideMyAssServer) {
|
||||
if a.HideMyAss.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]HideMyAssServer, len(a.HideMyAss.Servers))
|
||||
for i, serverToCopy := range a.HideMyAss.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetHideMyAss() (servers []Server) {
|
||||
return copyServers(a.HideMyAss.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetIpvanish() (servers []IpvanishServer) {
|
||||
if a.Ipvanish.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]IpvanishServer, len(a.Ipvanish.Servers))
|
||||
for i, serverToCopy := range a.Ipvanish.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetIpvanish() (servers []Server) {
|
||||
return copyServers(a.Ipvanish.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetIvpn() (servers []IvpnServer) {
|
||||
if a.Ivpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]IvpnServer, len(a.Ivpn.Servers))
|
||||
for i, serverToCopy := range a.Ivpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetIvpn() (servers []Server) {
|
||||
return copyServers(a.Ivpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetMullvad() (servers []MullvadServer) {
|
||||
if a.Mullvad.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]MullvadServer, len(a.Mullvad.Servers))
|
||||
for i, serverToCopy := range a.Mullvad.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetMullvad() (servers []Server) {
|
||||
return copyServers(a.Mullvad.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetNordvpn() (servers []NordvpnServer) {
|
||||
if a.Nordvpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]NordvpnServer, len(a.Nordvpn.Servers))
|
||||
for i, serverToCopy := range a.Nordvpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetNordvpn() (servers []Server) {
|
||||
return copyServers(a.Nordvpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetPerfectprivacy() (servers []PerfectprivacyServer) {
|
||||
if a.Perfectprivacy.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]PerfectprivacyServer, len(a.Perfectprivacy.Servers))
|
||||
for i, serverToCopy := range a.Perfectprivacy.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetPerfectprivacy() (servers []Server) {
|
||||
return copyServers(a.Perfectprivacy.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetPia() (servers []PIAServer) {
|
||||
if a.Pia.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]PIAServer, len(a.Pia.Servers))
|
||||
for i, serverToCopy := range a.Pia.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetPia() (servers []Server) {
|
||||
return copyServers(a.Pia.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetPrivado() (servers []PrivadoServer) {
|
||||
if a.Privado.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]PrivadoServer, len(a.Privado.Servers))
|
||||
for i, serverToCopy := range a.Privado.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetPrivado() (servers []Server) {
|
||||
return copyServers(a.Privado.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetPrivatevpn() (servers []PrivatevpnServer) {
|
||||
if a.Privatevpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]PrivatevpnServer, len(a.Privatevpn.Servers))
|
||||
for i, serverToCopy := range a.Privatevpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetPrivatevpn() (servers []Server) {
|
||||
return copyServers(a.Privatevpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetProtonvpn() (servers []ProtonvpnServer) {
|
||||
if a.Protonvpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]ProtonvpnServer, len(a.Protonvpn.Servers))
|
||||
for i, serverToCopy := range a.Protonvpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetProtonvpn() (servers []Server) {
|
||||
return copyServers(a.Protonvpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetPurevpn() (servers []PurevpnServer) {
|
||||
if a.Purevpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]PurevpnServer, len(a.Purevpn.Servers))
|
||||
for i, serverToCopy := range a.Purevpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetPurevpn() (servers []Server) {
|
||||
return copyServers(a.Purevpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetSurfshark() (servers []SurfsharkServer) {
|
||||
if a.Surfshark.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]SurfsharkServer, len(a.Surfshark.Servers))
|
||||
for i, serverToCopy := range a.Surfshark.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetSurfshark() (servers []Server) {
|
||||
return copyServers(a.Surfshark.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetTorguard() (servers []TorguardServer) {
|
||||
if a.Torguard.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]TorguardServer, len(a.Torguard.Servers))
|
||||
for i, serverToCopy := range a.Torguard.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetTorguard() (servers []Server) {
|
||||
return copyServers(a.Torguard.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetVPNUnlimited() (servers []VPNUnlimitedServer) {
|
||||
if a.VPNUnlimited.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]VPNUnlimitedServer, len(a.VPNUnlimited.Servers))
|
||||
for i, serverToCopy := range a.VPNUnlimited.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetVPNUnlimited() (servers []Server) {
|
||||
return copyServers(a.VPNUnlimited.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetVyprvpn() (servers []VyprvpnServer) {
|
||||
if a.Vyprvpn.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]VyprvpnServer, len(a.Vyprvpn.Servers))
|
||||
for i, serverToCopy := range a.Vyprvpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetVyprvpn() (servers []Server) {
|
||||
return copyServers(a.Vyprvpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetWevpn() (servers []WevpnServer) {
|
||||
if a.Windscribe.Servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]WevpnServer, len(a.Wevpn.Servers))
|
||||
for i, serverToCopy := range a.Wevpn.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
}
|
||||
return servers
|
||||
func (a *AllServers) GetWevpn() (servers []Server) {
|
||||
return copyServers(a.Wevpn.Servers)
|
||||
}
|
||||
|
||||
func (a *AllServers) GetWindscribe() (servers []WindscribeServer) {
|
||||
if a.Windscribe.Servers == nil {
|
||||
func (a *AllServers) GetWindscribe() (servers []Server) {
|
||||
return copyServers(a.Windscribe.Servers)
|
||||
}
|
||||
|
||||
func copyServers(servers []Server) (serversCopy []Server) {
|
||||
if servers == nil {
|
||||
return nil
|
||||
}
|
||||
servers = make([]WindscribeServer, len(a.Windscribe.Servers))
|
||||
for i, serverToCopy := range a.Windscribe.Servers {
|
||||
servers[i] = serverToCopy
|
||||
servers[i].IPs = copyIPs(serverToCopy.IPs)
|
||||
|
||||
serversCopy = make([]Server, len(servers))
|
||||
for i, server := range servers {
|
||||
serversCopy[i] = server
|
||||
serversCopy[i].IPs = copyIPs(server.IPs)
|
||||
}
|
||||
return servers
|
||||
|
||||
return serversCopy
|
||||
}
|
||||
|
||||
func copyIPs(toCopy []net.IP) (copied []net.IP) {
|
||||
|
||||
@@ -10,100 +10,100 @@ import (
|
||||
|
||||
func Test_AllServers_GetCopy(t *testing.T) {
|
||||
allServers := AllServers{
|
||||
Cyberghost: CyberghostServers{
|
||||
Cyberghost: Servers{
|
||||
Version: 2,
|
||||
Servers: []CyberghostServer{{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Expressvpn: ExpressvpnServers{
|
||||
Servers: []ExpressvpnServer{{
|
||||
Expressvpn: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Fastestvpn: FastestvpnServers{
|
||||
Servers: []FastestvpnServer{{
|
||||
Fastestvpn: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
HideMyAss: HideMyAssServers{
|
||||
Servers: []HideMyAssServer{{
|
||||
HideMyAss: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Ipvanish: IpvanishServers{
|
||||
Servers: []IpvanishServer{{
|
||||
Ipvanish: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Ivpn: IvpnServers{
|
||||
Servers: []IvpnServer{{
|
||||
Ivpn: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Mullvad: MullvadServers{
|
||||
Servers: []MullvadServer{{
|
||||
Mullvad: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Nordvpn: NordvpnServers{
|
||||
Servers: []NordvpnServer{{
|
||||
Nordvpn: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Perfectprivacy: PerfectprivacyServers{
|
||||
Servers: []PerfectprivacyServer{{
|
||||
Perfectprivacy: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Privado: PrivadoServers{
|
||||
Servers: []PrivadoServer{{
|
||||
Privado: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Pia: PiaServers{
|
||||
Servers: []PIAServer{{
|
||||
Pia: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Privatevpn: PrivatevpnServers{
|
||||
Servers: []PrivatevpnServer{{
|
||||
Privatevpn: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Protonvpn: ProtonvpnServers{
|
||||
Servers: []ProtonvpnServer{{
|
||||
Protonvpn: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Purevpn: PurevpnServers{
|
||||
Purevpn: Servers{
|
||||
Version: 1,
|
||||
Servers: []PurevpnServer{{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Surfshark: SurfsharkServers{
|
||||
Servers: []SurfsharkServer{{
|
||||
Surfshark: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Torguard: TorguardServers{
|
||||
Servers: []TorguardServer{{
|
||||
Torguard: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
VPNUnlimited: VPNUnlimitedServers{
|
||||
Servers: []VPNUnlimitedServer{{
|
||||
VPNUnlimited: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Vyprvpn: VyprvpnServers{
|
||||
Servers: []VyprvpnServer{{
|
||||
Vyprvpn: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
Windscribe: WindscribeServers{
|
||||
Servers: []WindscribeServer{{
|
||||
Windscribe: Servers{
|
||||
Servers: []Server{{
|
||||
IPs: []net.IP{{1, 2, 3, 4}},
|
||||
}},
|
||||
},
|
||||
@@ -116,8 +116,8 @@ func Test_AllServers_GetCopy(t *testing.T) {
|
||||
|
||||
func Test_AllServers_GetVyprvpn(t *testing.T) {
|
||||
allServers := AllServers{
|
||||
Vyprvpn: VyprvpnServers{
|
||||
Servers: []VyprvpnServer{
|
||||
Vyprvpn: Servers{
|
||||
Servers: []Server{
|
||||
{Hostname: "a", IPs: []net.IP{{1, 1, 1, 1}}},
|
||||
{Hostname: "b", IPs: []net.IP{{2, 2, 2, 2}}},
|
||||
},
|
||||
@@ -126,7 +126,7 @@ func Test_AllServers_GetVyprvpn(t *testing.T) {
|
||||
|
||||
servers := allServers.GetVyprvpn()
|
||||
|
||||
expectedServers := []VyprvpnServer{
|
||||
expectedServers := []Server{
|
||||
{Hostname: "a", IPs: []net.IP{{1, 1, 1, 1}}},
|
||||
{Hostname: "b", IPs: []net.IP{{2, 2, 2, 2}}},
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package models
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
)
|
||||
|
||||
func boolToMarkdown(b bool) string {
|
||||
@@ -14,280 +16,126 @@ func boolToMarkdown(b bool) string {
|
||||
|
||||
func markdownTableHeading(legendFields ...string) (markdown string) {
|
||||
return "| " + strings.Join(legendFields, " | ") + " |\n" +
|
||||
"|" + strings.Repeat(" --- |", len(legendFields)) + "\n"
|
||||
"|" + strings.Repeat(" --- |", len(legendFields))
|
||||
}
|
||||
|
||||
func (s *CyberghostServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
const (
|
||||
vpnHeader = "VPN"
|
||||
countryHeader = "Country"
|
||||
regionHeader = "Region"
|
||||
cityHeader = "City"
|
||||
ispHeader = "ISP"
|
||||
ownedHeader = "Owned"
|
||||
numberHeader = "Number"
|
||||
hostnameHeader = "Hostname"
|
||||
tcpHeader = "TCP"
|
||||
udpHeader = "UDP"
|
||||
multiHopHeader = "MultiHop"
|
||||
freeHeader = "Free"
|
||||
streamHeader = "Stream"
|
||||
portForwardHeader = "Port forwarding"
|
||||
)
|
||||
|
||||
func (s *Server) ToMarkdown(headers ...string) (markdown string) {
|
||||
if len(headers) == 0 {
|
||||
return ""
|
||||
}
|
||||
|
||||
fields := make([]string, len(headers))
|
||||
for i, header := range headers {
|
||||
switch header {
|
||||
case vpnHeader:
|
||||
fields[i] = s.VPN
|
||||
case countryHeader:
|
||||
fields[i] = s.Country
|
||||
case regionHeader:
|
||||
fields[i] = s.Region
|
||||
case cityHeader:
|
||||
fields[i] = s.City
|
||||
case ispHeader:
|
||||
fields[i] = s.ISP
|
||||
case ownedHeader:
|
||||
fields[i] = boolToMarkdown(s.Owned)
|
||||
case numberHeader:
|
||||
fields[i] = fmt.Sprint(s.Number)
|
||||
case hostnameHeader:
|
||||
fields[i] = fmt.Sprintf("`%s`", s.Hostname)
|
||||
case tcpHeader:
|
||||
fields[i] = boolToMarkdown(s.TCP)
|
||||
case udpHeader:
|
||||
fields[i] = boolToMarkdown(s.UDP)
|
||||
case multiHopHeader:
|
||||
fields[i] = boolToMarkdown(s.MultiHop)
|
||||
case freeHeader:
|
||||
fields[i] = boolToMarkdown(s.Free)
|
||||
case streamHeader:
|
||||
fields[i] = boolToMarkdown(s.Stream)
|
||||
case portForwardHeader:
|
||||
fields[i] = boolToMarkdown(s.PortForward)
|
||||
}
|
||||
}
|
||||
|
||||
return "| " + strings.Join(fields, " | ") + " |"
|
||||
}
|
||||
|
||||
func (s *Servers) ToMarkdown(vpnProvider string) (markdown string) {
|
||||
headers := getMarkdownHeaders(vpnProvider)
|
||||
|
||||
legend := markdownTableHeading(headers...)
|
||||
|
||||
entries := make([]string, len(s.Servers))
|
||||
for i, server := range s.Servers {
|
||||
entries[i] = server.ToMarkdown(headers...)
|
||||
}
|
||||
|
||||
markdown = legend + "\n" +
|
||||
strings.Join(entries, "\n") + "\n"
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s CyberghostServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | `%s` | %s | %s |", s.Country, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *ExpressvpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "City", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
func getMarkdownHeaders(vpnProvider string) (headers []string) {
|
||||
switch vpnProvider {
|
||||
case providers.Cyberghost:
|
||||
return []string{countryHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.Expressvpn:
|
||||
return []string{countryHeader, cityHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.Fastestvpn:
|
||||
return []string{countryHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.HideMyAss:
|
||||
return []string{countryHeader, regionHeader, cityHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.Ipvanish:
|
||||
return []string{countryHeader, cityHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.Ivpn:
|
||||
return []string{countryHeader, cityHeader, ispHeader, hostnameHeader, vpnHeader, tcpHeader, udpHeader}
|
||||
case providers.Mullvad:
|
||||
return []string{countryHeader, cityHeader, ispHeader, ownedHeader, hostnameHeader, vpnHeader}
|
||||
case providers.Nordvpn:
|
||||
return []string{countryHeader, regionHeader, cityHeader, hostnameHeader}
|
||||
case providers.Perfectprivacy:
|
||||
return []string{cityHeader, tcpHeader, udpHeader}
|
||||
case providers.Privado:
|
||||
return []string{countryHeader, regionHeader, cityHeader, hostnameHeader}
|
||||
case providers.PrivateInternetAccess:
|
||||
return []string{regionHeader, hostnameHeader, tcpHeader, udpHeader, portForwardHeader}
|
||||
case providers.Privatevpn:
|
||||
return []string{countryHeader, cityHeader, hostnameHeader}
|
||||
case providers.Protonvpn:
|
||||
return []string{countryHeader, regionHeader, cityHeader, hostnameHeader, freeHeader}
|
||||
case providers.Purevpn:
|
||||
return []string{countryHeader, regionHeader, cityHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.Surfshark:
|
||||
return []string{regionHeader, countryHeader, cityHeader, hostnameHeader, multiHopHeader, tcpHeader, udpHeader}
|
||||
case providers.Torguard:
|
||||
return []string{countryHeader, cityHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.VPNUnlimited:
|
||||
return []string{countryHeader, cityHeader, hostnameHeader, freeHeader, streamHeader, tcpHeader, udpHeader}
|
||||
case providers.Vyprvpn:
|
||||
return []string{regionHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.Wevpn:
|
||||
return []string{cityHeader, hostnameHeader, tcpHeader, udpHeader}
|
||||
case providers.Windscribe:
|
||||
return []string{regionHeader, cityHeader, hostnameHeader, vpnHeader}
|
||||
default:
|
||||
return nil
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *ExpressvpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | `%s` | %s | %s |",
|
||||
s.Country, s.City, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *FastestvpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *FastestvpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | `%s` | %s | %s |",
|
||||
s.Country, s.Hostname, boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *HideMyAssServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "Region", "City", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *HideMyAssServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | %s | `%s` | %s | %s |",
|
||||
s.Country, s.Region, s.City, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *IpvanishServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "City", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *IpvanishServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | `%s` | %s | %s |",
|
||||
s.Country, s.City, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *IvpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "City", "ISP", "Hostname", "VPN", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *IvpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | %s | `%s` | %s | %s | %s |",
|
||||
s.Country, s.City, s.ISP, s.Hostname, s.VPN,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *MullvadServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "City", "ISP", "Owned",
|
||||
"Hostname", "VPN")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *MullvadServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | %s | %s | `%s` | %s |",
|
||||
s.Country, s.City, s.ISP, boolToMarkdown(s.Owned),
|
||||
s.Hostname, s.VPN)
|
||||
}
|
||||
|
||||
func (s *NordvpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Region", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *NordvpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | `%s` | %s | %s |",
|
||||
s.Region, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *PrivadoServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "Region", "City", "Hostname")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *PrivadoServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | %s | `%s` |",
|
||||
s.Country, s.Region, s.City, s.Hostname)
|
||||
}
|
||||
|
||||
func (s *PerfectprivacyServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("City", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *PerfectprivacyServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | %s |",
|
||||
s.City, boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *PiaServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Region", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *PIAServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | `%s` | %s | %s |",
|
||||
s.Region, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *PrivatevpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "City", "Hostname")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *PrivatevpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | `%s` |",
|
||||
s.Country, s.City, s.Hostname)
|
||||
}
|
||||
|
||||
func (s *ProtonvpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "Region", "City", "Hostname", "Free tier")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *ProtonvpnServer) ToMarkdown() (markdown string) {
|
||||
isFree := strings.Contains(strings.ToLower(s.Name), "free")
|
||||
return fmt.Sprintf("| %s | %s | %s | `%s` | %s |",
|
||||
s.Country, s.Region, s.City, s.Hostname, boolToMarkdown(isFree))
|
||||
}
|
||||
|
||||
func (s *PurevpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "Region", "City", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *PurevpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | %s | `%s` | %s | %s |",
|
||||
s.Country, s.Region, s.City, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *SurfsharkServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Region", "Country", "City", "Hostname", "Multi-hop", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *SurfsharkServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | %s | `%s` | %s | %s | %s |",
|
||||
s.Region, s.Country, s.City, s.Hostname, boolToMarkdown(s.MultiHop),
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *TorguardServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "City", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *TorguardServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | `%s` | %s | %s |",
|
||||
s.Country, s.City, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *VPNUnlimitedServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Country", "City", "Hostname", "Free tier", "Streaming", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *VPNUnlimitedServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | `%s` | %s | %s | %s | %s |",
|
||||
s.Country, s.City, s.Hostname,
|
||||
boolToMarkdown(s.Free), boolToMarkdown(s.Stream),
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *VyprvpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Region", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *VyprvpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | `%s` | %s | %s |",
|
||||
s.Region, s.Hostname,
|
||||
boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *WevpnServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("City", "Hostname", "TCP", "UDP")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *WevpnServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | `%s` | %s | %s |",
|
||||
s.City, s.Hostname, boolToMarkdown(s.TCP), boolToMarkdown(s.UDP))
|
||||
}
|
||||
|
||||
func (s *WindscribeServers) ToMarkdown() (markdown string) {
|
||||
markdown = markdownTableHeading("Region", "City", "Hostname", "VPN")
|
||||
for _, server := range s.Servers {
|
||||
markdown += server.ToMarkdown() + "\n"
|
||||
}
|
||||
return markdown
|
||||
}
|
||||
|
||||
func (s *WindscribeServer) ToMarkdown() (markdown string) {
|
||||
return fmt.Sprintf("| %s | %s | `%s` | %s |",
|
||||
s.Region, s.City, s.Hostname, s.VPN)
|
||||
}
|
||||
|
||||
@@ -3,43 +3,54 @@ package models
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/qdm12/gluetun/internal/constants/providers"
|
||||
"github.com/stretchr/testify/assert"
|
||||
)
|
||||
|
||||
func Test_CyberghostServers_ToMarkdown(t *testing.T) {
|
||||
func Test_Servers_ToMarkdown(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
servers := CyberghostServers{
|
||||
Servers: []CyberghostServer{
|
||||
{Country: "a", UDP: true, Hostname: "xa"},
|
||||
{Country: "b", TCP: true, Hostname: "xb"},
|
||||
testCases := map[string]struct {
|
||||
provider string
|
||||
servers Servers
|
||||
expectedMarkdown string
|
||||
}{
|
||||
providers.Cyberghost: {
|
||||
provider: providers.Cyberghost,
|
||||
servers: Servers{
|
||||
Servers: []Server{
|
||||
{Country: "a", UDP: true, Hostname: "xa"},
|
||||
{Country: "b", TCP: true, Hostname: "xb"},
|
||||
},
|
||||
},
|
||||
expectedMarkdown: "| Country | Hostname | TCP | UDP |\n" +
|
||||
"| --- | --- | --- | --- |\n" +
|
||||
"| a | `xa` | ❌ | ✅ |\n" +
|
||||
"| b | `xb` | ✅ | ❌ |\n",
|
||||
},
|
||||
providers.Fastestvpn: {
|
||||
provider: providers.Fastestvpn,
|
||||
servers: Servers{
|
||||
Servers: []Server{
|
||||
{Country: "a", Hostname: "xa", TCP: true},
|
||||
{Country: "b", Hostname: "xb", UDP: true},
|
||||
},
|
||||
},
|
||||
expectedMarkdown: "| Country | Hostname | TCP | UDP |\n" +
|
||||
"| --- | --- | --- | --- |\n" +
|
||||
"| a | `xa` | ✅ | ❌ |\n" +
|
||||
"| b | `xb` | ❌ | ✅ |\n",
|
||||
},
|
||||
}
|
||||
|
||||
markdown := servers.ToMarkdown()
|
||||
const expected = "| Country | Hostname | TCP | UDP |\n" +
|
||||
"| --- | --- | --- | --- |\n" +
|
||||
"| a | `xa` | ❌ | ✅ |\n" +
|
||||
"| b | `xb` | ✅ | ❌ |\n"
|
||||
for name, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
assert.Equal(t, expected, markdown)
|
||||
}
|
||||
markdown := testCase.servers.ToMarkdown(testCase.provider)
|
||||
|
||||
func Test_FastestvpnServers_ToMarkdown(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
servers := FastestvpnServers{
|
||||
Servers: []FastestvpnServer{
|
||||
{Country: "a", Hostname: "xa", TCP: true},
|
||||
{Country: "b", Hostname: "xb", UDP: true},
|
||||
},
|
||||
assert.Equal(t, testCase.expectedMarkdown, markdown)
|
||||
})
|
||||
}
|
||||
|
||||
markdown := servers.ToMarkdown()
|
||||
const expected = "| Country | Hostname | TCP | UDP |\n" +
|
||||
"| --- | --- | --- | --- |\n" +
|
||||
"| a | `xa` | ✅ | ❌ |\n" +
|
||||
"| b | `xb` | ❌ | ✅ |\n"
|
||||
|
||||
assert.Equal(t, expected, markdown)
|
||||
}
|
||||
|
||||
@@ -4,187 +4,25 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
type CyberghostServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type ExpressvpnServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type FastestvpnServer struct {
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type HideMyAssServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type IpvanishServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type IvpnServer struct {
|
||||
VPN string `json:"vpn,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
ISP string `json:"isp,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
WgPubKey string `json:"wgpubkey,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type MullvadServer struct {
|
||||
VPN string `json:"vpn,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
ISP string `json:"isp,omitempty"`
|
||||
Owned bool `json:"owned,omitempty"`
|
||||
WgPubKey string `json:"wgpubkey,omitempty"`
|
||||
}
|
||||
|
||||
type NordvpnServer struct { //nolint:maligned
|
||||
Region string `json:"region,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
Number uint16 `json:"number,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
}
|
||||
|
||||
type PerfectprivacyServer struct {
|
||||
City string `json:"city,omitempty"` // primary key
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
}
|
||||
|
||||
type PrivadoServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type PIAServer struct {
|
||||
type Server struct {
|
||||
VPN string `json:"vpn,omitempty"`
|
||||
// Surfshark: country is also used for multi-hop
|
||||
Country string `json:"country,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
ISP string `json:"isp,omitempty"`
|
||||
Owned bool `json:"owned,omitempty"`
|
||||
Number uint16 `json:"number,omitempty"`
|
||||
ServerName string `json:"server_name,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
OvpnX509 string `json:"x509,omitempty"`
|
||||
RetroLoc string `json:"retroloc,omitempty"` // TODO remove in v4
|
||||
MultiHop bool `json:"multihop,omitempty"`
|
||||
WgPubKey string `json:"wgpubkey,omitempty"`
|
||||
Free bool `json:"free,omitempty"`
|
||||
Stream bool `json:"stream,omitempty"`
|
||||
PortForward bool `json:"port_forward,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type PrivatevpnServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type ProtonvpnServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Name string `json:"server_name,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type PurevpnServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type SurfsharkServer struct {
|
||||
Region string `json:"region,omitempty"`
|
||||
Country string `json:"country,omitempty"` // Country is also used for multi-hop
|
||||
City string `json:"city,omitempty"`
|
||||
RetroLoc string `json:"retroloc,omitempty"` // TODO remove in v4
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
MultiHop bool `json:"multihop,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type TorguardServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type VPNUnlimitedServer struct {
|
||||
Country string `json:"country,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
Free bool `json:"free,omitempty"`
|
||||
Stream bool `json:"stream,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type VyprvpnServer struct {
|
||||
Region string `json:"region,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"` // only support for UDP
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type WevpnServer struct {
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
TCP bool `json:"tcp,omitempty"`
|
||||
UDP bool `json:"udp,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
type WindscribeServer struct {
|
||||
VPN string `json:"vpn,omitempty"`
|
||||
Region string `json:"region,omitempty"`
|
||||
City string `json:"city,omitempty"`
|
||||
Hostname string `json:"hostname,omitempty"`
|
||||
OvpnX509 string `json:"x509,omitempty"`
|
||||
WgPubKey string `json:"wgpubkey,omitempty"`
|
||||
IPs []net.IP `json:"ips,omitempty"`
|
||||
}
|
||||
|
||||
@@ -1,27 +1,27 @@
|
||||
package models
|
||||
|
||||
type AllServers struct {
|
||||
Version uint16 `json:"version"` // used for migration of the top level scheme
|
||||
Cyberghost CyberghostServers `json:"cyberghost"`
|
||||
Expressvpn ExpressvpnServers `json:"expressvpn"`
|
||||
Fastestvpn FastestvpnServers `json:"fastestvpn"`
|
||||
HideMyAss HideMyAssServers `json:"hidemyass"`
|
||||
Ipvanish IpvanishServers `json:"ipvanish"`
|
||||
Ivpn IvpnServers `json:"ivpn"`
|
||||
Mullvad MullvadServers `json:"mullvad"`
|
||||
Perfectprivacy PerfectprivacyServers `json:"perfectprivacy"`
|
||||
Nordvpn NordvpnServers `json:"nordvpn"`
|
||||
Privado PrivadoServers `json:"privado"`
|
||||
Pia PiaServers `json:"pia"`
|
||||
Privatevpn PrivatevpnServers `json:"privatevpn"`
|
||||
Protonvpn ProtonvpnServers `json:"protonvpn"`
|
||||
Purevpn PurevpnServers `json:"purevpn"`
|
||||
Surfshark SurfsharkServers `json:"surfshark"`
|
||||
Torguard TorguardServers `json:"torguard"`
|
||||
VPNUnlimited VPNUnlimitedServers `json:"vpnunlimited"`
|
||||
Vyprvpn VyprvpnServers `json:"vyprvpn"`
|
||||
Wevpn WevpnServers `json:"wevpn"`
|
||||
Windscribe WindscribeServers `json:"windscribe"`
|
||||
Version uint16 `json:"version"` // used for migration of the top level scheme
|
||||
Cyberghost Servers `json:"cyberghost"`
|
||||
Expressvpn Servers `json:"expressvpn"`
|
||||
Fastestvpn Servers `json:"fastestvpn"`
|
||||
HideMyAss Servers `json:"hidemyass"`
|
||||
Ipvanish Servers `json:"ipvanish"`
|
||||
Ivpn Servers `json:"ivpn"`
|
||||
Mullvad Servers `json:"mullvad"`
|
||||
Perfectprivacy Servers `json:"perfectprivacy"`
|
||||
Nordvpn Servers `json:"nordvpn"`
|
||||
Privado Servers `json:"privado"`
|
||||
Pia Servers `json:"pia"`
|
||||
Privatevpn Servers `json:"privatevpn"`
|
||||
Protonvpn Servers `json:"protonvpn"`
|
||||
Purevpn Servers `json:"purevpn"`
|
||||
Surfshark Servers `json:"surfshark"`
|
||||
Torguard Servers `json:"torguard"`
|
||||
VPNUnlimited Servers `json:"vpnunlimited"`
|
||||
Vyprvpn Servers `json:"vyprvpn"`
|
||||
Wevpn Servers `json:"wevpn"`
|
||||
Windscribe Servers `json:"windscribe"`
|
||||
}
|
||||
|
||||
func (a *AllServers) Count() int {
|
||||
@@ -47,103 +47,8 @@ func (a *AllServers) Count() int {
|
||||
len(a.Windscribe.Servers)
|
||||
}
|
||||
|
||||
type CyberghostServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []CyberghostServer `json:"servers"`
|
||||
}
|
||||
type ExpressvpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []ExpressvpnServer `json:"servers"`
|
||||
}
|
||||
type FastestvpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []FastestvpnServer `json:"servers"`
|
||||
}
|
||||
type HideMyAssServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []HideMyAssServer `json:"servers"`
|
||||
}
|
||||
type IpvanishServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []IpvanishServer `json:"servers"`
|
||||
}
|
||||
type IvpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []IvpnServer `json:"servers"`
|
||||
}
|
||||
type MullvadServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []MullvadServer `json:"servers"`
|
||||
}
|
||||
type NordvpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []NordvpnServer `json:"servers"`
|
||||
}
|
||||
type PerfectprivacyServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []PerfectprivacyServer `json:"servers"`
|
||||
}
|
||||
type PrivadoServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []PrivadoServer `json:"servers"`
|
||||
}
|
||||
type PiaServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []PIAServer `json:"servers"`
|
||||
}
|
||||
type PrivatevpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []PrivatevpnServer `json:"servers"`
|
||||
}
|
||||
type ProtonvpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []ProtonvpnServer `json:"servers"`
|
||||
}
|
||||
type PurevpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []PurevpnServer `json:"servers"`
|
||||
}
|
||||
type SurfsharkServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []SurfsharkServer `json:"servers"`
|
||||
}
|
||||
type TorguardServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []TorguardServer `json:"servers"`
|
||||
}
|
||||
type VPNUnlimitedServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []VPNUnlimitedServer `json:"servers"`
|
||||
}
|
||||
type VyprvpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []VyprvpnServer `json:"servers"`
|
||||
}
|
||||
type WevpnServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []WevpnServer `json:"servers"`
|
||||
}
|
||||
type WindscribeServers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []WindscribeServer `json:"servers"`
|
||||
type Servers struct {
|
||||
Version uint16 `json:"version"`
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
Servers []Server `json:"servers"`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user