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 8345753
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
10 changes: 3 additions & 7 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,
// 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
Expand Down
11 changes: 9 additions & 2 deletions internal/experiment/openvpn/endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ var (
)

// endpoint is a single endpoint to be probed.
// The information contained in here is not generally not sufficient to complete a connection:
// we need more info, as cipher selection or obfuscating proxy credentials.
// The information contained in here is not sufficient to complete a connection:
// we need to augment it with more info, as cipher selection or obfuscating proxy credentials.
type endpoint struct {
// IPAddr is the IP Address for this endpoint.
IPAddr string
Expand Down 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 8345753

Please sign in to comment.