@@ -48,9 +48,15 @@ public class ProxyActivity extends AbstractActivity {
48
48
*
49
49
* 1. an empty string means no proxy;
50
50
*
51
- * 2. "psiphon://" means that we wanna use psiphon;
51
+ * 2. "psiphon:/// " means that we want to use psiphon;
52
52
*
53
- * 3. "socks5://1.2.3.4:5678" or "socks5://[::1]:5678" or "socks5://d.com:5678"
53
+ * 3. "tor:///" means we want to use tor without any proxy (which is possible
54
+ * because oonimkall embeds `libtor.a` as a dependency);
55
+ *
56
+ * 4. "torsf:///" is like "tor:///" but additionally uses the snowflake
57
+ * library we also bundle inside of oonimkall;
58
+ *
59
+ * 5. "socks5://1.2.3.4:5678" or "socks5://[::1]:5678" or "socks5://d.com:5678"
54
60
* means that we wanna use the given socks5 proxy.
55
61
*
56
62
* Future improvements
@@ -67,8 +73,6 @@ public class ProxyActivity extends AbstractActivity {
67
73
* This implies we can trivially support a vanilla socks5 proxy with username and
68
74
* password by just replacing `psiphon+socks5` with `socks5`.
69
75
*
70
- * We also want to support vanilla tor, using `tor://`.
71
- *
72
76
* We also want to support vanilla tor with socks5, which is trivially doable
73
77
* using as a scheme the `tor+socks5` scheme.
74
78
*
@@ -93,15 +97,20 @@ public class ProxyActivity extends AbstractActivity {
93
97
* The design and implementation of this class owes to the code contributed
94
98
* by and the suggestion from friendly anonymous users. Thank you!
95
99
*/
100
+
101
+ // logger is the injected AppLogger instance.
96
102
@ Inject
97
103
AppLogger logger ;
104
+
98
105
// TAG is the tag used for logging.
99
106
private final static String TAG = "ProxyActivity" ;
100
107
108
+ // preferenceManager is the injected PreferenceManager instance.
101
109
@ Inject
102
110
PreferenceManager preferenceManager ;
103
- // The following radio group describes the top level choice
104
- // in terms of proxying: no proxy, psiphon, or custom.
111
+
112
+ // The following radio group describes the top level choice in terms of
113
+ // proxying: no proxy, psiphon, tor, torsf, or custom.
105
114
106
115
// proxyRadioGroup is the top-level radio group.
107
116
private RadioGroup proxyRadioGroup ;
@@ -112,12 +121,21 @@ public class ProxyActivity extends AbstractActivity {
112
121
// proxyPsiphonRB is the radio button selecting the "psiphon" proxy.
113
122
private RadioButton proxyPsiphonRB ;
114
123
124
+ // proxyTorRB is the radio button selecting the "tor" proxy.
125
+ private RadioButton proxyTorRB ;
126
+
127
+ // proxyTorSfRB is the radio button selecting the "torsf" proxy.
128
+ private RadioButton proxyTorSfRB ;
129
+
115
130
// proxyCustomRB is the radio button for the "custom" proxy.
116
131
private RadioButton proxyCustomRB ;
117
132
118
133
// The following radio group allows users to choose which specific
119
134
// custom proxy they would like to use. When writing this documentation,
120
135
// only socks5 is available but we will add more options.
136
+ //
137
+ // TODO(bassosimone): we need to implement support for HTTP proxies
138
+ // once https://github.com/ooni/probe-cli/pull/1162 lands.
121
139
122
140
// customProxyRadioGroup allows you to choose among the different
123
141
// kinds of custom proxies that are available.
@@ -153,6 +171,8 @@ public void onCreate(Bundle savedInstanceState) {
153
171
proxyRadioGroup = findViewById (R .id .proxyRadioGroup );
154
172
proxyNoneRB = findViewById (R .id .proxyNone );
155
173
proxyPsiphonRB = findViewById (R .id .proxyPsiphon );
174
+ proxyTorRB = findViewById (R .id .proxyTor );
175
+ proxyTorSfRB = findViewById (R .id .proxyTorSf );
156
176
proxyCustomRB = findViewById (R .id .proxyCustom );
157
177
customProxyRadioGroup = findViewById (R .id .customProxyRadioGroup );
158
178
customProxySOCKS5 = findViewById (R .id .customProxySOCKS5 );
@@ -196,6 +216,10 @@ private void configureInitialViewWithSettings(ProxySettings settings) {
196
216
proxyNoneRB .setChecked (true );
197
217
} else if (settings .protocol == ProxyProtocol .PSIPHON ) {
198
218
proxyPsiphonRB .setChecked (true );
219
+ } else if (settings .protocol == ProxyProtocol .TOR ) {
220
+ proxyTorRB .setChecked (true );
221
+ } else if (settings .protocol == ProxyProtocol .TORSF ) {
222
+ proxyTorSfRB .setChecked (true );
199
223
} else if (settings .protocol == ProxyProtocol .SOCKS5 ) {
200
224
proxyCustomRB .setChecked (true );
201
225
} else {
@@ -226,6 +250,10 @@ private void configureInitialViewWithSettings(ProxySettings settings) {
226
250
customProxySetEnabled (false );
227
251
} else if (checkedId == R .id .proxyPsiphon ) {
228
252
customProxySetEnabled (false );
253
+ } else if (checkedId == R .id .proxyTor ) {
254
+ customProxySetEnabled (false );
255
+ } else if (checkedId == R .id .proxyTorSf ) {
256
+ customProxySetEnabled (false );
229
257
} else if (checkedId == R .id .proxyCustom ) {
230
258
customProxySetEnabled (true );
231
259
customProxyRadioGroup .clearCheck ();
@@ -364,6 +392,24 @@ public void onBackPressed() {
364
392
return ;
365
393
}
366
394
395
+ // If the tor proxy is checked then write back the right
396
+ // proxy configuration for tor and move on.
397
+ if (proxyTorRB .isChecked ()) {
398
+ settings .protocol = ProxyProtocol .TOR ;
399
+ saveSettings ();
400
+ super .onBackPressed ();
401
+ return ;
402
+ }
403
+
404
+ // If the torsf proxy is checked then write back the right
405
+ // proxy configuration for torsf and move on.
406
+ if (proxyTorSfRB .isChecked ()) {
407
+ settings .protocol = ProxyProtocol .TORSF ;
408
+ saveSettings ();
409
+ super .onBackPressed ();
410
+ return ;
411
+ }
412
+
367
413
// validate the hostname for the custom proxy.
368
414
if (!isValidHostnameOrIP (hostname )) {
369
415
customProxyHostname .setError ("not a valid hostname or IP" );
0 commit comments