chore(validation): move functions from constants
- Move validation functions from `internal/constants` to `internal/configuration/settings/validation` - Concatenate all OpenVPN constants in `internal/constants/openvpn.go`
This commit is contained in:
@@ -18,7 +18,8 @@ func addServersFromAPI(ctx context.Context, client *http.Client,
|
||||
return err
|
||||
}
|
||||
|
||||
hostToLocation := constants.SurfsharkHostToLocation()
|
||||
locationData := constants.SurfsharkLocationData()
|
||||
hostToLocation := hostToLocation(locationData)
|
||||
|
||||
const tcp, udp = true, true
|
||||
for _, serverData := range data {
|
||||
|
||||
@@ -20,3 +20,12 @@ func getHostInformation(host string, hostnameToLocation map[string]models.Surfsh
|
||||
|
||||
return locationData, nil
|
||||
}
|
||||
|
||||
func hostToLocation(locationData []models.SurfsharkLocationData) (
|
||||
hostToLocation map[string]models.SurfsharkLocationData) {
|
||||
hostToLocation = make(map[string]models.SurfsharkLocationData, len(locationData))
|
||||
for _, data := range locationData {
|
||||
hostToLocation[data.Hostname] = data
|
||||
}
|
||||
return hostToLocation
|
||||
}
|
||||
|
||||
@@ -6,7 +6,8 @@ import (
|
||||
|
||||
// getRemainingServers finds extra servers not found in the API or in the ZIP file.
|
||||
func getRemainingServers(hts hostToServer) {
|
||||
hostnameToLocationLeft := constants.SurfsharkHostToLocation()
|
||||
locationData := constants.SurfsharkLocationData()
|
||||
hostnameToLocationLeft := hostToLocation(locationData)
|
||||
for _, hostnameDone := range hts.toHostsSlice() {
|
||||
delete(hostnameToLocationLeft, hostnameDone)
|
||||
}
|
||||
|
||||
@@ -24,7 +24,8 @@ func addOpenVPNServersFromZip(ctx context.Context,
|
||||
hostnamesDoneSet[hostname] = struct{}{}
|
||||
}
|
||||
|
||||
hostToLocation := constants.SurfsharkHostToLocation()
|
||||
locationData := constants.SurfsharkLocationData()
|
||||
hostToLocation := hostToLocation(locationData)
|
||||
|
||||
for fileName, content := range contents {
|
||||
if !strings.HasSuffix(fileName, ".ovpn") {
|
||||
|
||||
Reference in New Issue
Block a user