Skip to content

Commit 4828c58

Browse files
bassosimonecyBerta
andauthored
refactor(riseupvpn): rename structs, change progress, bump version (#1361)
This diff renames some structs, changes the code emitting the progress, and bumps the experiment version. In my previous commit, I said I did bump the version number but that was not actually the case. This diff has been extracted from #1125. This diff is part of ooni/probe#1432 --------- Co-authored-by: cyBerta <[email protected]>
1 parent 82b11fc commit 4828c58

File tree

2 files changed

+23
-18
lines changed

2 files changed

+23
-18
lines changed

internal/experiment/riseupvpn/riseupvpn.go

+21-16
Original file line numberDiff line numberDiff line change
@@ -16,25 +16,28 @@ import (
1616

1717
const (
1818
testName = "riseupvpn"
19-
testVersion = "0.2.0"
19+
testVersion = "0.3.0"
2020
eipServiceURL = "https://api.black.riseup.net:443/3/config/eip-service.json"
2121
providerURL = "https://riseup.net/provider.json"
2222
geoServiceURL = "https://api.black.riseup.net:9001/json"
2323
tcpConnect = "tcpconnect://"
2424
)
2525

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

31+
// CapabilitiesV3 is a list of transports a gateway supports
32+
type CapabilitiesV3 struct {
33+
Transport []TransportV3
34+
}
35+
3136
// GatewayV3 describes a gateway.
3237
type GatewayV3 struct {
33-
Capabilities struct {
34-
Transport []TransportV3
35-
}
36-
Host string
37-
IPAddress string `json:"ip_address"`
38+
Capabilities CapabilitiesV3
39+
Host string
40+
IPAddress string `json:"ip_address"`
3841
}
3942

4043
// TransportV3 describes a transport.
@@ -203,7 +206,7 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
203206
FailOnHTTPError: true,
204207
}},
205208
}
206-
for entry := range multi.CollectOverall(ctx, inputs, 0, 50, "riseupvpn", callbacks) {
209+
for entry := range multi.CollectOverall(ctx, inputs, 0, 20, "riseupvpn", callbacks) {
207210
tk := entry.TestKeys
208211
testkeys.AddCACertFetchTestKeys(tk)
209212
if tk.Failure != nil {
@@ -241,7 +244,7 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
241244
FailOnHTTPError: true,
242245
}},
243246
}
244-
for entry := range multi.CollectOverall(ctx, inputs, 1, 50, "riseupvpn", callbacks) {
247+
for entry := range multi.CollectOverall(ctx, inputs, 1, 20, "riseupvpn", callbacks) {
245248
testkeys.UpdateProviderAPITestKeys(entry)
246249
}
247250

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

255259
// measure openvpn in parallel
256260
for entry := range multi.CollectOverall(
257-
ctx, openvpnEndpoints, 1+len(inputs), overallCount, "riseupvpn", callbacks) {
261+
ctx, openvpnEndpoints, startCount, overallCount, "riseupvpn", callbacks) {
258262
testkeys.AddGatewayConnectTestKeys(entry, "openvpn")
259263
}
260264

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

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

315-
// DecodeEIP3 decodes eip-service.json version 3
316-
func DecodeEIP3(body string) (*EipService, error) {
317-
var eip EipService
320+
// DecodeEIPServiceV3 decodes eip-service.json version 3
321+
func DecodeEIPServiceV3(body string) (*EIPServiceV3, error) {
322+
var eip EIPServiceV3
318323
err := json.Unmarshal([]byte(body), &eip)
319324
if err != nil {
320325
return nil, err

internal/experiment/riseupvpn/riseupvpn_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func TestNewExperimentMeasurer(t *testing.T) {
203203
if measurer.ExperimentName() != "riseupvpn" {
204204
t.Fatal("unexpected name")
205205
}
206-
if measurer.ExperimentVersion() != "0.2.0" {
206+
if measurer.ExperimentVersion() != "0.3.0" {
207207
t.Fatal("unexpected version")
208208
}
209209
}
@@ -549,7 +549,7 @@ func TestFailureTransport(t *testing.T) {
549549
}
550550

551551
func TestMissingTransport(t *testing.T) {
552-
eipService, err := riseupvpn.DecodeEIP3(eipservice)
552+
eipService, err := riseupvpn.DecodeEIPServiceV3(eipservice)
553553
if err != nil {
554554
t.Fatal("Preconditions for the test are not met.")
555555
}

0 commit comments

Comments
 (0)