From 5557a97ba3379bf20fdef1a846c26efebd84ab40 Mon Sep 17 00:00:00 2001 From: ain ghazal Date: Wed, 3 Apr 2024 15:56:34 +0200 Subject: [PATCH] move list of enabled providers to expriment/openvpn --- internal/engine/inputloader.go | 10 +++------- internal/experiment/openvpn/endpoint.go | 7 +++++++ internal/experiment/openvpn/openvpn.go | 1 - 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/internal/engine/inputloader.go b/internal/engine/inputloader.go index 3612d1b34..861be897f 100644 --- a/internal/engine/inputloader.go +++ b/internal/engine/inputloader.go @@ -331,19 +331,15 @@ func (il *InputLoader) loadRemoteWebConnectivity(ctx context.Context) ([]model.O return reply.WebConnectivity.URLs, nil } -// These are the providers that are enabled in the API. -var openvpnDefaultProviders = []string{ - "riseup", -} - // loadRemoteOpenVPN loads openvpn inputs from a remote source. func (il *InputLoader) loadRemoteOpenVPN(ctx context.Context) ([]model.OOAPIURLInfo, error) { // VPN Inputs do not match exactly the semantics expected from [model.OOAPIURLInfo], - // since OOAPIURLInfo is oriented twards webconnectivity, + // since OOAPIURLInfo is oriented towards webconnectivity, // but we force VPN targets in the URL and ignore all the other fields. urls := make([]model.OOAPIURLInfo, 0) - for _, provider := range openvpnDefaultProviders { + // The openvpn experiment contains an array of the providers that the API knows about. + for _, provider := range openvpn.APIEnabledProviders { reply, err := il.vpnConfig(ctx, provider) if err != nil { break diff --git a/internal/experiment/openvpn/endpoint.go b/internal/experiment/openvpn/endpoint.go index 0d3c9616e..c1c1b9312 100644 --- a/internal/experiment/openvpn/endpoint.go +++ b/internal/experiment/openvpn/endpoint.go @@ -174,6 +174,13 @@ var defaultOptionsByProvider = map[string]*vpnconfig.OpenVPNOptions{ }, } +// APIEnabledProviders is the list of providers that the stable API Endpoint knows about. +// This array will be a subset of the keys in defaultOptionsByProvider, but it might make sense +// to still register info about more providers that the API officially knows about. +var APIEnabledProviders = []string{ + "riseup", +} + // isValidProvider returns true if the provider is found as key in the registry of defaultOptionsByProvider. // TODO(ainghazal): consolidate with list of enabled providers from the API viewpoint. func isValidProvider(provider string) bool { diff --git a/internal/experiment/openvpn/openvpn.go b/internal/experiment/openvpn/openvpn.go index fe55f0380..5d500e738 100644 --- a/internal/experiment/openvpn/openvpn.go +++ b/internal/experiment/openvpn/openvpn.go @@ -31,7 +31,6 @@ var ( // of this experiment. By tagging these variables with `ooni:"..."`, we allow // miniooni's -O flag to find them and set them. type Config struct { - // TODO(ainghazal): Provider is right now ignored. InputLoader should get the provider from options. Provider string `ooni:"VPN provider"` SafeKey string `ooni:"key to connect to the OpenVPN endpoint"` SafeCert string `ooni:"cert to connect to the OpenVPN endpoint"`