chore(models): common Server & Servers for all providers (#943)
This commit is contained in:
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
type hostToServer map[string]models.PrivatevpnServer
|
||||
type hostToServer map[string]models.Server
|
||||
|
||||
// TODO check if server supports TCP and UDP.
|
||||
func (hts hostToServer) add(host, country, city string) {
|
||||
@@ -41,8 +41,8 @@ func (hts hostToServer) adaptWithIPs(hostToIPs map[string][]net.IP) {
|
||||
}
|
||||
}
|
||||
|
||||
func (hts hostToServer) toServersSlice() (servers []models.PrivatevpnServer) {
|
||||
servers = make([]models.PrivatevpnServer, 0, len(hts))
|
||||
func (hts hostToServer) toServersSlice() (servers []models.Server) {
|
||||
servers = make([]models.Server, 0, len(hts))
|
||||
for _, server := range hts {
|
||||
servers = append(servers, server)
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ var ErrNotEnoughServers = errors.New("not enough servers found")
|
||||
|
||||
func GetServers(ctx context.Context, unzipper unzip.Unzipper,
|
||||
presolver resolver.Parallel, minServers int) (
|
||||
servers []models.PrivatevpnServer, warnings []string, err error) {
|
||||
servers []models.Server, warnings []string, err error) {
|
||||
const url = "https://privatevpn.com/client/PrivateVPN-TUN.zip"
|
||||
contents, err := unzipper.FetchAndExtract(ctx, url)
|
||||
if err != nil {
|
||||
@@ -32,7 +32,7 @@ func GetServers(ctx context.Context, unzipper unzip.Unzipper,
|
||||
countryCodes := constants.CountryCodes()
|
||||
|
||||
hts := make(hostToServer)
|
||||
noHostnameServers := make([]models.PrivatevpnServer, 0, 1) // there is only one for now
|
||||
noHostnameServers := make([]models.Server, 0, 1) // there is only one for now
|
||||
|
||||
for fileName, content := range contents {
|
||||
if !strings.HasSuffix(fileName, ".ovpn") {
|
||||
@@ -69,7 +69,7 @@ func GetServers(ctx context.Context, unzipper unzip.Unzipper,
|
||||
warnings = append(warnings, warning)
|
||||
continue
|
||||
}
|
||||
server := models.PrivatevpnServer{
|
||||
server := models.Server{
|
||||
Country: country,
|
||||
City: city,
|
||||
IPs: ips,
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
)
|
||||
|
||||
func sortServers(servers []models.PrivatevpnServer) {
|
||||
func sortServers(servers []models.Server) {
|
||||
sort.Slice(servers, func(i, j int) bool {
|
||||
if servers[i].Country == servers[j].Country {
|
||||
if servers[i].City == servers[j].City {
|
||||
|
||||
Reference in New Issue
Block a user