2021-05-08 00:59:42 +00:00
|
|
|
// Package cyberghost contains code to obtain the server information
|
|
|
|
|
// for the Cyberghost provider.
|
|
|
|
|
package cyberghost
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"context"
|
2022-06-06 01:57:44 +00:00
|
|
|
"sort"
|
2021-05-08 00:59:42 +00:00
|
|
|
|
|
|
|
|
"github.com/qdm12/gluetun/internal/models"
|
|
|
|
|
)
|
|
|
|
|
|
2022-06-07 16:47:35 +00:00
|
|
|
func (u *Updater) FetchServers(ctx context.Context, minServers int) (
|
2022-05-28 20:58:50 +00:00
|
|
|
servers []models.Server, err error) {
|
2021-05-08 00:59:42 +00:00
|
|
|
possibleServers := getPossibleServers()
|
|
|
|
|
|
|
|
|
|
possibleHosts := possibleServers.hostsSlice()
|
2022-05-28 20:58:50 +00:00
|
|
|
hostToIPs, err := resolveHosts(ctx, u.presolver, possibleHosts, minServers)
|
2021-05-08 00:59:42 +00:00
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
possibleServers.adaptWithIPs(hostToIPs)
|
|
|
|
|
|
|
|
|
|
servers = possibleServers.toSlice()
|
|
|
|
|
|
2022-06-06 01:57:44 +00:00
|
|
|
sort.Sort(models.SortableServers(servers))
|
|
|
|
|
|
2021-05-08 00:59:42 +00:00
|
|
|
return servers, nil
|
|
|
|
|
}
|