Skip to content

Commit a9d8054

Browse files
authored
chore: use probe-cli v3.19.0 (#622)
Part of ooni/probe#2524 ## Proposed Changes - Enable `echcheck` ooni/probe#2567. - Add support for appending errors
1 parent 1457054 commit a9d8054

File tree

12 files changed

+107
-122
lines changed

12 files changed

+107
-122
lines changed

app/src/main/java/org/openobservatory/ooniprobe/activity/OverviewActivity.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public static Intent newIntent(Context context, AbstractSuite testSuite) {
5858
String experimentalLinks =
5959
"\n\n* [STUN Reachability](https://github.com/ooni/spec/blob/master/nettests/ts-025-stun-reachability.md)" +
6060
"\n\n* [DNS Check](https://github.com/ooni/spec/blob/master/nettests/ts-028-dnscheck.md)" +
61+
"\n\n* [ECH Check](https://github.com/ooni/spec/blob/master/nettests/ts-039-echcheck.md)" +
6162
"\n\n* [Tor Snowflake](https://ooni.org/nettest/tor-snowflake/) "+ String.format(" ( %s )",getString(R.string.Settings_TestOptions_LongRunningTest))+
6263
"\n\n* [Vanilla Tor](https://github.com/ooni/spec/blob/master/nettests/ts-016-vanilla-tor.md) " + String.format(" ( %s )",getString(R.string.Settings_TestOptions_LongRunningTest));
6364
Markwon.setMarkdown(binding.desc, getString(testSuite.getDesc1(), experimentalLinks));

app/src/main/java/org/openobservatory/ooniprobe/activity/ProxyActivity.java

Lines changed: 38 additions & 79 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,23 @@
44
import android.util.Log;
55
import android.view.KeyEvent;
66
import android.view.MenuItem;
7-
import android.widget.RadioButton;
8-
import android.widget.RadioGroup;
9-
import android.widget.TextView;
10-
117
import androidx.annotation.NonNull;
12-
138
import com.google.android.material.textfield.TextInputLayout;
149
import com.google.common.net.InetAddresses;
1510
import com.google.common.net.InternetDomainName;
16-
1711
import org.openobservatory.ooniprobe.R;
1812
import org.openobservatory.ooniprobe.common.AppLogger;
1913
import org.openobservatory.ooniprobe.common.PreferenceManager;
2014
import org.openobservatory.ooniprobe.common.ProxyProtocol;
2115
import org.openobservatory.ooniprobe.common.ProxySettings;
16+
import org.openobservatory.ooniprobe.databinding.ActivityProxyBinding;
17+
import ru.noties.markwon.Markwon;
2218

19+
import javax.inject.Inject;
2320
import java.net.URISyntaxException;
21+
import java.util.Arrays;
2422
import java.util.Objects;
2523

26-
import javax.inject.Inject;
27-
28-
import ru.noties.markwon.Markwon;
29-
3024
/**
3125
* The ProxyActivity is part of the Settings. It allows users to
3226
* configure the proxy for speaking with OONI's backends.
@@ -103,36 +97,8 @@ public class ProxyActivity extends AbstractActivity {
10397
// The following radio group describes the top level choice
10498
// in terms of proxying: no proxy, psiphon, or custom.
10599

106-
// proxyRadioGroup is the top-level radio group.
107-
private RadioGroup proxyRadioGroup;
108-
109-
// proxyNoneRB is the radio button selecting the "none" proxy.
110-
private RadioButton proxyNoneRB;
111-
112-
// proxyPsiphonRB is the radio button selecting the "psiphon" proxy.
113-
private RadioButton proxyPsiphonRB;
114-
115-
// proxyCustomRB is the radio button for the "custom" proxy.
116-
private RadioButton proxyCustomRB;
117-
118-
// The following radio group allows users to choose which specific
119-
// custom proxy they would like to use. When writing this documentation,
120-
// only socks5 is available but we will add more options.
121-
122-
// customProxyRadioGroup allows you to choose among the different
123-
// kinds of custom proxies that are available.
124-
private RadioGroup customProxyRadioGroup;
125-
126-
// customProxySOCKS5 selects the custom SOCKS5 proxy type.
127-
private RadioButton customProxySOCKS5;
128-
129-
// The following settings allow users to configure the custom proxy.
130-
131-
// customProxyHostname is the hostname for the custom proxy.
132-
private TextInputLayout customProxyHostname;
100+
ActivityProxyBinding binding;
133101

134-
// customProxyPort is the port for the custom proxy.
135-
private TextInputLayout customProxyPort;
136102

137103
// settings contains a representation of the proxy settings
138104
// loaded from the preference manager.
@@ -147,21 +113,13 @@ public void onCreate(Bundle savedInstanceState) {
147113
super.onCreate(savedInstanceState);
148114
getActivityComponent().inject(this);
149115

116+
binding = ActivityProxyBinding.inflate(getLayoutInflater());
150117
// We draw the view and store references to objects needed
151118
// when configuring the initial view or modifying it.
152-
setContentView(R.layout.activity_proxy);
153-
proxyRadioGroup = findViewById(R.id.proxyRadioGroup);
154-
proxyNoneRB = findViewById(R.id.proxyNone);
155-
proxyPsiphonRB = findViewById(R.id.proxyPsiphon);
156-
proxyCustomRB = findViewById(R.id.proxyCustom);
157-
customProxyRadioGroup = findViewById(R.id.customProxyRadioGroup);
158-
customProxySOCKS5 = findViewById(R.id.customProxySOCKS5);
159-
customProxyHostname = findViewById(R.id.customProxyHostname);
160-
customProxyPort = findViewById(R.id.customProxyPort);
119+
setContentView(binding.getRoot());
161120

162121
// We fill the footer that helps users to understand this settings screen.
163-
TextView proxyFooter = findViewById(R.id.proxyFooter);
164-
Markwon.setMarkdown(proxyFooter, getString(R.string.Settings_Proxy_Footer));
122+
Markwon.setMarkdown(binding.proxyFooter, getString(R.string.Settings_Proxy_Footer));
165123

166124
// We read settings and configure the initial view.
167125
loadSettingsAndConfigureInitialView();
@@ -193,11 +151,12 @@ private void configureInitialViewWithSettings(ProxySettings settings) {
193151
// Inspect the scheme and use the scheme to choose among the
194152
// top-level radio buttons describing the proxy type.
195153
if (settings.protocol == ProxyProtocol.NONE) {
196-
proxyNoneRB.setChecked(true);
154+
binding.proxyNone.setChecked(true);
197155
} else if (settings.protocol == ProxyProtocol.PSIPHON) {
198-
proxyPsiphonRB.setChecked(true);
199-
} else if (settings.protocol == ProxyProtocol.SOCKS5) {
200-
proxyCustomRB.setChecked(true);
156+
binding.proxyPsiphon.setChecked(true);
157+
} else if (Arrays.asList(getResources().getStringArray(R.array.proxy_protocol_list)).contains(settings.protocol.getProtocol())) {
158+
binding.customProxyProtocol.setText(settings.protocol.getProtocol(),false);
159+
binding.proxyCustom.setChecked(true);
201160
} else {
202161
// TODO(bassosimone): this should also be reported as a bug.
203162
Log.w(TAG, "got an unhandled proxy scheme");
@@ -208,28 +167,28 @@ private void configureInitialViewWithSettings(ProxySettings settings) {
208167
// If the scheme is custom, then we need to enable the
209168
// part of the view related to custom proxies.
210169
customProxySetEnabled(isSchemeCustom(settings.protocol));
211-
customProxySOCKS5.setChecked(isSchemeCustom(settings.protocol));
212170

213171
// Populate all the editable fields _anyway_ so the user
214172
// has the feeling that everything was just as before
173+
Log.d(TAG, "(from preferences) protocol: " + settings.protocol);
174+
logger.i(TAG, "(from preferences) protocol: " + settings.protocol);
215175
Log.d(TAG, "(from preferences) hostname: " + settings.hostname);
216176
logger.i(TAG, "(from preferences) hostname: " + settings.hostname);
217177
Log.d(TAG, "(from preferences) port: " + settings.port);
218178
logger.i(TAG, "(from preferences) port: " + settings.port);
219-
Objects.requireNonNull(customProxyHostname.getEditText()).setText(settings.hostname);
220-
Objects.requireNonNull(customProxyPort.getEditText()).setText(settings.port);
179+
Objects.requireNonNull(binding.customProxyHostname.getEditText()).setText(settings.hostname);
180+
Objects.requireNonNull(binding.customProxyPort.getEditText()).setText(settings.port);
221181

222182
// Now we need to make the top level proxy radio group interactive: when
223183
// we change what is selected, we need the view to adapt.
224-
proxyRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
184+
binding.proxyRadioGroup.setOnCheckedChangeListener((group, checkedId) -> {
225185
if (checkedId == R.id.proxyNone) {
226186
customProxySetEnabled(false);
227187
} else if (checkedId == R.id.proxyPsiphon) {
228188
customProxySetEnabled(false);
229189
} else if (checkedId == R.id.proxyCustom) {
230190
customProxySetEnabled(true);
231-
customProxyRadioGroup.clearCheck();
232-
customProxySOCKS5.setChecked(true);
191+
binding.customProxyRadioGroup.clearCheck();
233192
} else {
234193
// TODO(bassosimone): this should also be reported as a bug.
235194
Log.w(TAG, "unexpected state in setOnCheckedChangeListener");
@@ -238,14 +197,14 @@ private void configureInitialViewWithSettings(ProxySettings settings) {
238197
});
239198

240199
// When we change the focus of text fields, clear any lingering error text.
241-
Objects.requireNonNull(customProxyHostname.getEditText()).setOnFocusChangeListener((v, hasFocus) -> {
200+
Objects.requireNonNull(binding.customProxyHostname.getEditText()).setOnFocusChangeListener((v, hasFocus) -> {
242201
if (!hasFocus) {
243-
customProxyHostname.setError(null);
202+
binding.customProxyHostname.setError(null);
244203
}
245204
});
246-
Objects.requireNonNull(customProxyPort.getEditText()).setOnFocusChangeListener((v, hasFocus) -> {
205+
Objects.requireNonNull(binding.customProxyPort.getEditText()).setOnFocusChangeListener((v, hasFocus) -> {
247206
if (!hasFocus) {
248-
customProxyHostname.setError(null);
207+
binding.customProxyHostname.setError(null);
249208
}
250209
});
251210
}
@@ -254,7 +213,7 @@ private void configureInitialViewWithSettings(ProxySettings settings) {
254213
private boolean isSchemeCustom(ProxyProtocol protocol) {
255214
// This is where we need to extend the implementation of we add a new scheme
256215
// that will not be related to a custom proxy type.
257-
return protocol == ProxyProtocol.SOCKS5;
216+
return protocol == ProxyProtocol.SOCKS5 || protocol == ProxyProtocol.HTTP || protocol == ProxyProtocol.HTTPS;
258217
}
259218

260219
// customProxyTextInputSetEnabled is a helper function that changes the
@@ -268,9 +227,8 @@ private void customProxyTextInputSetEnabled(@NonNull TextInputLayout input, bool
268227
// customProxySetEnabled reacts to the enabling or disabling of the custom
269228
// proxy group and changes the view accordingly to that.
270229
private void customProxySetEnabled(boolean flag) {
271-
customProxySOCKS5.setEnabled(flag);
272-
customProxyTextInputSetEnabled(customProxyHostname, flag);
273-
customProxyTextInputSetEnabled(customProxyPort, flag);
230+
customProxyTextInputSetEnabled(binding.customProxyHostname, flag);
231+
customProxyTextInputSetEnabled(binding.customProxyPort, flag);
274232
}
275233

276234
// isValidHostnameOrIP validates its input as an IP address or hostname.
@@ -341,14 +299,14 @@ public void onBackPressed() {
341299
logger.i(TAG, "onBackPressed: about to save proxy settings");
342300

343301
// Get the hostname and port for the custom proxy.
344-
String hostname = Objects.requireNonNull(customProxyHostname.getEditText()).getText().toString();
345-
String port = Objects.requireNonNull(customProxyPort.getEditText()).getText().toString();
302+
String hostname = Objects.requireNonNull(binding.customProxyHostname.getEditText()).getText().toString();
303+
String port = Objects.requireNonNull(binding.customProxyPort.getEditText()).getText().toString();
346304
settings.hostname = hostname;
347305
settings.port = port;
348306

349307
// If no proxy is selected then just write an empty proxy
350308
// configuration into the settings and move on.
351-
if (proxyNoneRB.isChecked()) {
309+
if (binding.proxyNone.isChecked()) {
352310
settings.protocol = ProxyProtocol.NONE;
353311
saveSettings();
354312
super.onBackPressed();
@@ -357,7 +315,7 @@ public void onBackPressed() {
357315

358316
// If the psiphon proxy is checked then write back the right
359317
// proxy configuration for psiphon and move on.
360-
if (proxyPsiphonRB.isChecked()) {
318+
if (binding.proxyPsiphon.isChecked()) {
361319
settings.protocol = ProxyProtocol.PSIPHON;
362320
saveSettings();
363321
super.onBackPressed();
@@ -366,26 +324,27 @@ public void onBackPressed() {
366324

367325
// validate the hostname for the custom proxy.
368326
if (!isValidHostnameOrIP(hostname)) {
369-
customProxyHostname.setError("not a valid hostname or IP");
327+
binding.customProxyHostname.setError("not a valid hostname or IP");
370328
return;
371329
}
372330

373331
// validate the port for the custom proxy.
374332
if (!isValidPort(port)) {
375-
customProxyPort.setError("not a valid network port");
333+
binding.customProxyPort.setError("not a valid network port");
376334
return;
377335
}
378336

379-
// At this point we're going to assume that this is a socks5 proxy. We will
380-
// need to change the code in here when we add support for http proxies.
381-
settings.protocol = ProxyProtocol.SOCKS5;
337+
// At this point we're going to assume that this is a socks5,http,https proxy.
338+
// ProxyProtocol.valueOf will only accept one of the values in ProxyProtocol
339+
// as in the enum definition(uppercase).
382340
try {
341+
settings.protocol = ProxyProtocol.valueOf(binding.customProxyProtocol.getText().toString().toUpperCase());
383342
settings.getProxyString();
384343
} catch (URISyntaxException e) {
385344
// okay, then, notwithstanding our efforts it still seems that we
386345
// have not obtained a valid URL, so let's not proceed.
387-
customProxyHostname.setError("cannot construct a valid URL");
388-
customProxyPort.setError("cannot construct a valid URL");
346+
binding.customProxyHostname.setError("cannot construct a valid URL");
347+
binding.customProxyPort.setError("cannot construct a valid URL");
389348
return;
390349
}
391350

app/src/main/java/org/openobservatory/ooniprobe/common/ProxyProtocol.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
public enum ProxyProtocol {
55
NONE("none"),
66
PSIPHON("psiphon"),
7-
SOCKS5("socks5");
7+
SOCKS5("socks5"),
8+
HTTP("http"),
9+
HTTPS("https");
810

911
private String protocol;
1012

app/src/main/java/org/openobservatory/ooniprobe/common/ProxySettings.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,10 @@ public static ProxySettings newProxySettings(PreferenceManager pm) throws Invali
3333
settings.protocol = ProxyProtocol.NONE;
3434
} else if (protocol.equals(ProxyProtocol.PSIPHON.getProtocol())) {
3535
settings.protocol = ProxyProtocol.PSIPHON;
36-
} else if (protocol.equals(ProxyProtocol.SOCKS5.getProtocol())) {
37-
settings.protocol = ProxyProtocol.SOCKS5;
36+
} else if (protocol.equals(ProxyProtocol.SOCKS5.getProtocol()) || protocol.equals(ProxyProtocol.HTTP.getProtocol()) || protocol.equals(ProxyProtocol.HTTPS.getProtocol())) {
37+
// ProxyProtocol.valueOf will only accept one of the values in ProxyProtocol
38+
// as in the enum definition(uppercase).
39+
settings.protocol = ProxyProtocol.valueOf(protocol.toUpperCase());
3840
} else {
3941
// This is where we will extend the code to add support for
4042
// more proxies, e.g., HTTP proxies.
@@ -72,16 +74,18 @@ private boolean isIPv6(String hostname) {
7274

7375
/** getProxyString returns to you the proxy string you should pass to oonimkall. */
7476
public String getProxyString() throws URISyntaxException {
75-
if (protocol == ProxyProtocol.NONE)
77+
if (protocol == ProxyProtocol.NONE) {
7678
return "";
77-
if (protocol == ProxyProtocol.PSIPHON)
79+
}
80+
if (protocol == ProxyProtocol.PSIPHON) {
7881
return "psiphon://";
79-
if (protocol == ProxyProtocol.SOCKS5) {
82+
}
83+
if (protocol == ProxyProtocol.SOCKS5||protocol == ProxyProtocol.HTTP||protocol == ProxyProtocol.HTTPS) {
8084
// Alright, we now need to construct a new SOCKS5 URL. We are going to defer
8185
// doing that to the Java standard library (er, the Android stdlib).
82-
String urlStr = "socks5://" + hostname + ":" + port + "/";
86+
String urlStr = protocol.getProtocol()+"://" + hostname + ":" + port + "/";
8387
if (isIPv6(hostname)) {
84-
urlStr = "socks5://[" + hostname + "]:" + port + "/"; // IPv6 must be quoted in URLs
88+
urlStr = protocol.getProtocol()+"://[" + hostname + "]:" + port + "/"; // IPv6 must be quoted in URLs
8589
}
8690
URI url = new URI(urlStr);
8791
return url.toASCIIString();

app/src/main/java/org/openobservatory/ooniprobe/test/suite/CircumventionSuite.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.openobservatory.ooniprobe.common.PreferenceManager;
99
import org.openobservatory.ooniprobe.test.test.AbstractTest;
1010
import org.openobservatory.ooniprobe.test.test.Psiphon;
11+
import org.openobservatory.ooniprobe.test.test.RiseupVPN;
1112
import org.openobservatory.ooniprobe.test.test.Tor;
1213

1314
import java.util.ArrayList;
@@ -43,11 +44,6 @@ public static CircumventionSuite initForAutoRun() {
4344
list.add(new Psiphon());
4445
if (pm == null || pm.isTestTor())
4546
list.add(new Tor());
46-
/* TODO (aanorbel): Riseup VPN Disabled.
47-
The riseupvpn experiment has been quite flaky for quite some time.
48-
To be enabled only when test is fixed or removed if deemed necessary.
49-
if (pm == null || pm.isTestRiseupVPN())
50-
list.add(new RiseupVPN());*/
5147
super.setTestList(Lists.transform(list, test -> {
5248
if (getAutoRun()) test.setOrigin(AbstractTest.AUTORUN);
5349
return test;

app/src/main/java/org/openobservatory/ooniprobe/test/suite/ExperimentalSuite.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,13 @@ public AbstractTest[] getTestList(@Nullable PreferenceManager pm) {
4040
if (super.getTestList(pm) == null) {
4141
ArrayList<AbstractTest> list = new ArrayList<>();
4242
if (pm == null || pm.isExperimentalOn()){
43+
list.add(new Experimental("stunreachability"));
44+
list.add(new Experimental("dnscheck"));
45+
list.add(new Experimental("echcheck"));
4346
if ((pm == null || pm.isLongRunningTestsInForeground()) || getAutoRun()){
4447
list.add(new Experimental("torsf"));
4548
list.add(new Experimental("vanilla_tor"));
46-
}
47-
list.add(new Experimental("stunreachability"));
48-
list.add(new Experimental("dnscheck"));
49+
}
4950
}
5051
super.setTestList(Lists.transform(list, test -> {
5152
if (getAutoRun()) test.setOrigin(AbstractTest.AUTORUN);

app/src/main/java/org/openobservatory/ooniprobe/test/test/AbstractTest.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,8 +319,14 @@ private void setDataUsage(EventResult.Value value, Result result) {
319319
}
320320

321321
private void setFailureMsg(EventResult.Value value, Result result) {
322-
if (result == null) return;
323-
result.failure_msg = value.failure;
322+
if (result == null) {
323+
return;
324+
}
325+
if (result.failure_msg == null) {
326+
result.failure_msg = value.failure;
327+
} else {
328+
result.failure_msg = String.format("%s\n\n%s", result.failure_msg, value.failure);
329+
}
324330
result.save();
325331
}
326332

0 commit comments

Comments
 (0)