Skip to content

Commit

Permalink
move list of enabled providers to expriment/openvpn
Browse files Browse the repository at this point in the history
  • Loading branch information
ainghazal committed Apr 3, 2024
1 parent a3e8a5b commit 267e87b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
8 changes: 2 additions & 6 deletions internal/engine/inputloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
// 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
Expand Down
7 changes: 7 additions & 0 deletions internal/experiment/openvpn/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
1 change: 0 additions & 1 deletion internal/experiment/openvpn/openvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down

0 comments on commit 267e87b

Please sign in to comment.