Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(riseupvpn): rename structs, change progress, bump version #1361

Merged
merged 2 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 21 additions & 16 deletions internal/experiment/riseupvpn/riseupvpn.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,28 @@ import (

const (
testName = "riseupvpn"
testVersion = "0.2.0"
testVersion = "0.3.0"
eipServiceURL = "https://api.black.riseup.net:443/3/config/eip-service.json"
providerURL = "https://riseup.net/provider.json"
geoServiceURL = "https://api.black.riseup.net:9001/json"
tcpConnect = "tcpconnect://"
)

// EipService is the main JSON object of eip-service.json.
type EipService struct {
// EIPServiceV3 is the main JSON object returned by eip-service.json.
type EIPServiceV3 struct {
Gateways []GatewayV3
}

// CapabilitiesV3 is a list of transports a gateway supports
type CapabilitiesV3 struct {
Transport []TransportV3
}

// GatewayV3 describes a gateway.
type GatewayV3 struct {
Capabilities struct {
Transport []TransportV3
}
Host string
IPAddress string `json:"ip_address"`
Capabilities CapabilitiesV3
Host string
IPAddress string `json:"ip_address"`
}

// TransportV3 describes a transport.
Expand Down Expand Up @@ -203,7 +206,7 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
FailOnHTTPError: true,
}},
}
for entry := range multi.CollectOverall(ctx, inputs, 0, 50, "riseupvpn", callbacks) {
for entry := range multi.CollectOverall(ctx, inputs, 0, 20, "riseupvpn", callbacks) {
tk := entry.TestKeys
testkeys.AddCACertFetchTestKeys(tk)
if tk.Failure != nil {
Expand Down Expand Up @@ -241,7 +244,7 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
FailOnHTTPError: true,
}},
}
for entry := range multi.CollectOverall(ctx, inputs, 1, 50, "riseupvpn", callbacks) {
for entry := range multi.CollectOverall(ctx, inputs, 1, 20, "riseupvpn", callbacks) {
testkeys.UpdateProviderAPITestKeys(entry)
}

Expand All @@ -251,19 +254,21 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
openvpnEndpoints := generateMultiInputs(gateways, "openvpn")
obfs4Endpoints := generateMultiInputs(gateways, "obfs4")
overallCount := 1 + len(inputs) + len(openvpnEndpoints) + len(obfs4Endpoints)
startCount := 1 + len(inputs)

// measure openvpn in parallel
for entry := range multi.CollectOverall(
ctx, openvpnEndpoints, 1+len(inputs), overallCount, "riseupvpn", callbacks) {
ctx, openvpnEndpoints, startCount, overallCount, "riseupvpn", callbacks) {
testkeys.AddGatewayConnectTestKeys(entry, "openvpn")
}

// measure obfs4 in parallel
// TODO(bassosimone): when urlgetter is able to do obfs4 handshakes, here
// can possibly also test for the obfs4 handshake.
// See https://github.com/ooni/probe/issues/1463.
startCount += len(openvpnEndpoints)
for entry := range multi.CollectOverall(
ctx, obfs4Endpoints, 1+len(inputs)+len(openvpnEndpoints), overallCount, "riseupvpn", callbacks) {
ctx, obfs4Endpoints, startCount, overallCount, "riseupvpn", callbacks) {
testkeys.AddGatewayConnectTestKeys(entry, "obfs4")
}

Expand Down Expand Up @@ -303,7 +308,7 @@ func parseGateways(testKeys *TestKeys) []GatewayV3 {
// TODO(bassosimone,cyberta): is it reasonable that we discard
// the error when the JSON we fetched cannot be parsed?
// See https://github.com/ooni/probe/issues/1432
eipService, err := DecodeEIP3(string(requestEntry.Response.Body))
eipService, err := DecodeEIPServiceV3(string(requestEntry.Response.Body))
if err == nil {
return eipService.Gateways
}
Expand All @@ -312,9 +317,9 @@ func parseGateways(testKeys *TestKeys) []GatewayV3 {
return nil
}

// DecodeEIP3 decodes eip-service.json version 3
func DecodeEIP3(body string) (*EipService, error) {
var eip EipService
// DecodeEIPServiceV3 decodes eip-service.json version 3
func DecodeEIPServiceV3(body string) (*EIPServiceV3, error) {
var eip EIPServiceV3
err := json.Unmarshal([]byte(body), &eip)
if err != nil {
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions internal/experiment/riseupvpn/riseupvpn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ func TestNewExperimentMeasurer(t *testing.T) {
if measurer.ExperimentName() != "riseupvpn" {
t.Fatal("unexpected name")
}
if measurer.ExperimentVersion() != "0.2.0" {
if measurer.ExperimentVersion() != "0.3.0" {
t.Fatal("unexpected version")
}
}
Expand Down Expand Up @@ -549,7 +549,7 @@ func TestFailureTransport(t *testing.T) {
}

func TestMissingTransport(t *testing.T) {
eipService, err := riseupvpn.DecodeEIP3(eipservice)
eipService, err := riseupvpn.DecodeEIPServiceV3(eipservice)
if err != nil {
t.Fatal("Preconditions for the test are not met.")
}
Expand Down