summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjwijenbergh <jeroenwijenbergh@protonmail.com>2022-11-14 11:01:03 +0100
committerjwijenbergh <jeroenwijenbergh@protonmail.com>2022-11-14 11:01:03 +0100
commitd9dd452748f524efc3e172f7181a8a538b9143c1 (patch)
treec5f85b6282e885a9a37ad479e44e160eecd74db4
parent25fdd94671d6b090992e8086334852dfd68f16d8 (diff)
Client + Server: Refresh the endpoints before checking for a valid profile
-rw-r--r--client/server.go7
-rw-r--r--internal/server/common.go14
2 files changed, 17 insertions, 4 deletions
diff --git a/client/server.go b/client/server.go
index b7bbb2a..5e1c31f 100644
--- a/client/server.go
+++ b/client/server.go
@@ -79,6 +79,13 @@ func (client *Client) getConfig(
)
}
+ // Refresh the server endpoints
+ // This is best effort
+ endpointErr := server.RefreshEndpoints(chosenServer)
+ if endpointErr != nil {
+ client.Logger.Warning(fmt.Sprintf("failed to refresh server endpoints: %v", endpointErr))
+ }
+
config, configType, configErr := client.retryConfigAuth(chosenServer, preferTCP)
if configErr != nil {
return "", "", types.NewWrappedError(errorMessage, configErr)
diff --git a/internal/server/common.go b/internal/server/common.go
index 1b745cb..7d711f0 100644
--- a/internal/server/common.go
+++ b/internal/server/common.go
@@ -473,21 +473,27 @@ func HasValidProfile(server Server, clientSupportsWireguard bool) (bool, error)
return false, nil
}
-func GetConfig(server Server, clientSupportsWireguard bool, preferTCP bool) (string, string, error) {
- errorMessage := "failed getting an OpenVPN/WireGuard configuration"
+func RefreshEndpoints(server Server) error {
+ errorMessage := "failed to refresh server endpoints"
// Re-initialize the endpoints
// TODO: Make this a warning instead?
base, baseErr := server.GetBase()
if baseErr != nil {
- return "", "", types.NewWrappedError(errorMessage, baseErr)
+ return types.NewWrappedError(errorMessage, baseErr)
}
endpointsErr := base.InitializeEndpoints()
if endpointsErr != nil {
- return "", "", types.NewWrappedError(errorMessage, endpointsErr)
+ return types.NewWrappedError(errorMessage, endpointsErr)
}
+ return nil
+}
+
+func GetConfig(server Server, clientSupportsWireguard bool, preferTCP bool) (string, string, error) {
+ errorMessage := "failed getting an OpenVPN/WireGuard configuration"
+
profile, profileErr := getCurrentProfile(server)
if profileErr != nil {
return "", "", types.NewWrappedError(errorMessage, profileErr)