9
9
"time"
10
10
11
11
"github.com/ooni/probe-cli/v3/internal/experiment/urlgetter"
12
- "github.com/ooni/probe-cli/v3/internal/legacy/tracex"
13
12
"github.com/ooni/probe-cli/v3/internal/model"
14
13
"github.com/ooni/probe-cli/v3/internal/netxlite"
15
14
)
@@ -63,21 +62,15 @@ type Config struct {
63
62
// TestKeys contains riseupvpn test keys.
64
63
type TestKeys struct {
65
64
urlgetter.TestKeys
66
- APIFailure * string `json:"api_failure"`
67
- APIStatus string `json:"api_status"`
68
- CACertStatus bool `json:"ca_cert_status"`
69
- FailingGateways []GatewayConnection `json:"failing_gateways"`
70
- TransportStatus map [string ]string `json:"transport_status"`
65
+ APIFailures []string `json:"api_failures"`
66
+ CACertStatus bool `json:"ca_cert_status"`
71
67
}
72
68
73
69
// NewTestKeys creates new riseupvpn TestKeys.
74
70
func NewTestKeys () * TestKeys {
75
71
return & TestKeys {
76
- APIFailure : nil ,
77
- APIStatus : "ok" ,
78
- CACertStatus : true ,
79
- FailingGateways : nil ,
80
- TransportStatus : nil ,
72
+ APIFailures : []string {},
73
+ CACertStatus : true ,
81
74
}
82
75
}
83
76
@@ -88,12 +81,8 @@ func (tk *TestKeys) UpdateProviderAPITestKeys(v urlgetter.MultiOutput) {
88
81
tk .Requests = append (tk .Requests , v .TestKeys .Requests ... )
89
82
tk .TCPConnect = append (tk .TCPConnect , v .TestKeys .TCPConnect ... )
90
83
tk .TLSHandshakes = append (tk .TLSHandshakes , v .TestKeys .TLSHandshakes ... )
91
- if tk .APIStatus != "ok" {
92
- return // we already flipped the state
93
- }
94
84
if v .TestKeys .Failure != nil {
95
- tk .APIStatus = "blocked"
96
- tk .APIFailure = v .TestKeys .Failure
85
+ tk .APIFailures = append (tk .APIFailures , * v .TestKeys .Failure )
97
86
return
98
87
}
99
88
}
@@ -104,42 +93,6 @@ func (tk *TestKeys) UpdateProviderAPITestKeys(v urlgetter.MultiOutput) {
104
93
func (tk * TestKeys ) AddGatewayConnectTestKeys (v urlgetter.MultiOutput , transportType string ) {
105
94
tk .NetworkEvents = append (tk .NetworkEvents , v .TestKeys .NetworkEvents ... )
106
95
tk .TCPConnect = append (tk .TCPConnect , v .TestKeys .TCPConnect ... )
107
- for _ , tcpConnect := range v .TestKeys .TCPConnect {
108
- if ! tcpConnect .Status .Success {
109
- gatewayConnection := newGatewayConnection (tcpConnect , transportType )
110
- tk .FailingGateways = append (tk .FailingGateways , * gatewayConnection )
111
- }
112
- }
113
- }
114
-
115
- func (tk * TestKeys ) updateTransportStatus (openvpnGatewayCount , obfs4GatewayCount int ) {
116
- failingOpenvpnGateways , failingObfs4Gateways := 0 , 0
117
- for _ , gw := range tk .FailingGateways {
118
- if gw .TransportType == "openvpn" {
119
- failingOpenvpnGateways ++
120
- } else if gw .TransportType == "obfs4" {
121
- failingObfs4Gateways ++
122
- }
123
- }
124
- if failingOpenvpnGateways < openvpnGatewayCount {
125
- tk .TransportStatus ["openvpn" ] = "ok"
126
- } else {
127
- tk .TransportStatus ["openvpn" ] = "blocked"
128
- }
129
- if failingObfs4Gateways < obfs4GatewayCount {
130
- tk .TransportStatus ["obfs4" ] = "ok"
131
- } else {
132
- tk .TransportStatus ["obfs4" ] = "blocked"
133
- }
134
- }
135
-
136
- func newGatewayConnection (
137
- tcpConnect tracex.TCPConnectEntry , transportType string ) * GatewayConnection {
138
- return & GatewayConnection {
139
- IP : tcpConnect .IP ,
140
- Port : tcpConnect .Port ,
141
- TransportType : transportType ,
142
- }
143
96
}
144
97
145
98
// AddCACertFetchTestKeys adds generic urlgetter.Get() testKeys to riseupvpn specific test keys
@@ -149,11 +102,6 @@ func (tk *TestKeys) AddCACertFetchTestKeys(testKeys urlgetter.TestKeys) {
149
102
tk .Requests = append (tk .Requests , testKeys .Requests ... )
150
103
tk .TCPConnect = append (tk .TCPConnect , testKeys .TCPConnect ... )
151
104
tk .TLSHandshakes = append (tk .TLSHandshakes , testKeys .TLSHandshakes ... )
152
- if testKeys .Failure != nil {
153
- tk .APIStatus = "blocked"
154
- tk .APIFailure = tk .Failure
155
- tk .CACertStatus = false
156
- }
157
105
}
158
106
159
107
// Measurer performs the measurement.
@@ -206,22 +154,24 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
206
154
FailOnHTTPError : true ,
207
155
}},
208
156
}
209
- for entry := range multi .CollectOverall (ctx , inputs , 0 , 20 , "riseupvpn" , callbacks ) {
157
+
158
+ nullCallbacks := model .NewPrinterCallbacks (model .DiscardLogger )
159
+ noTLSVerify := true
160
+ for entry := range multi .CollectOverall (ctx , inputs , 0 , 20 , "riseupvpn" , nullCallbacks ) {
210
161
tk := entry .TestKeys
211
162
testkeys .AddCACertFetchTestKeys (tk )
212
163
if tk .Failure != nil {
213
- // TODO(bassosimone,cyberta): should we update the testkeys
214
- // in this case (e.g., APIFailure?)
215
- // See https://github.com/ooni/probe/issues/1432.
216
- return nil
164
+ testkeys .CACertStatus = false
165
+ testkeys .APIFailures = append (testkeys .APIFailures , * tk .Failure )
166
+ continue
217
167
}
218
168
if ok := certPool .AppendCertsFromPEM ([]byte (tk .HTTPResponseBody )); ! ok {
219
169
testkeys .CACertStatus = false
220
- testkeys .APIStatus = "blocked"
221
- errorValue := "invalid_ca"
222
- testkeys .APIFailure = & errorValue
223
- return nil
170
+ testkeys .APIFailures = append (testkeys .APIFailures , "invalid_ca" )
171
+ continue
224
172
}
173
+ // We have a CA so we can verify certificates
174
+ noTLSVerify = false
225
175
}
226
176
227
177
// Now test the service endpoints using the above-fetched CA
@@ -232,24 +182,26 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
232
182
CertPool : certPool ,
233
183
Method : "GET" ,
234
184
FailOnHTTPError : true ,
185
+ NoTLSVerify : noTLSVerify ,
235
186
}},
236
187
{Target : eipServiceURL , Config : urlgetter.Config {
237
188
CertPool : certPool ,
238
189
Method : "GET" ,
239
190
FailOnHTTPError : true ,
191
+ NoTLSVerify : noTLSVerify ,
240
192
}},
241
193
{Target : geoServiceURL , Config : urlgetter.Config {
242
194
CertPool : certPool ,
243
195
Method : "GET" ,
244
196
FailOnHTTPError : true ,
197
+ NoTLSVerify : noTLSVerify ,
245
198
}},
246
199
}
247
- for entry := range multi .CollectOverall (ctx , inputs , 1 , 20 , "riseupvpn" , callbacks ) {
200
+ for entry := range multi .CollectOverall (ctx , inputs , 1 , 20 , "riseupvpn" , nullCallbacks ) {
248
201
testkeys .UpdateProviderAPITestKeys (entry )
249
202
}
250
203
251
204
// test gateways now
252
- testkeys .TransportStatus = map [string ]string {}
253
205
gateways := parseGateways (testkeys )
254
206
openvpnEndpoints := generateMultiInputs (gateways , "openvpn" )
255
207
obfs4Endpoints := generateMultiInputs (gateways , "obfs4" )
@@ -272,8 +224,6 @@ func (m Measurer) Run(ctx context.Context, args *model.ExperimentArgs) error {
272
224
testkeys .AddGatewayConnectTestKeys (entry , "obfs4" )
273
225
}
274
226
275
- // set transport status based on gateway test results
276
- testkeys .updateTransportStatus (len (openvpnEndpoints ), len (obfs4Endpoints ))
277
227
return nil
278
228
}
279
229
0 commit comments