chore(filter): common filter for all providers
This commit is contained in:
@@ -15,7 +15,7 @@ func (f *Fastestvpn) GetConnection(selection settings.ServerSelection) (
|
||||
protocol = constants.TCP
|
||||
}
|
||||
|
||||
servers, err := f.filterServers(selection)
|
||||
servers, err := utils.FilterServers(f.servers, selection)
|
||||
if err != nil {
|
||||
return connection, err
|
||||
}
|
||||
|
||||
@@ -1,27 +0,0 @@
|
||||
package fastestvpn
|
||||
|
||||
import (
|
||||
"github.com/qdm12/gluetun/internal/configuration/settings"
|
||||
"github.com/qdm12/gluetun/internal/models"
|
||||
"github.com/qdm12/gluetun/internal/provider/utils"
|
||||
)
|
||||
|
||||
func (f *Fastestvpn) filterServers(selection settings.ServerSelection) (
|
||||
servers []models.Server, err error) {
|
||||
for _, server := range f.servers {
|
||||
switch {
|
||||
case
|
||||
utils.FilterByPossibilities(server.Country, selection.Countries),
|
||||
utils.FilterByPossibilities(server.Hostname, selection.Hostnames),
|
||||
utils.FilterByProtocol(selection, server.TCP, server.UDP):
|
||||
default:
|
||||
servers = append(servers, server)
|
||||
}
|
||||
}
|
||||
|
||||
if len(servers) == 0 {
|
||||
return nil, utils.NoServerFoundError(selection)
|
||||
}
|
||||
|
||||
return servers, nil
|
||||
}
|
||||
Reference in New Issue
Block a user