... |
... |
@@ -28,40 +28,19 @@ import java.net.URLConnection; |
28
|
28
|
import java.util.List;
|
29
|
29
|
|
30
|
30
|
public class ProxySelector {
|
31
|
|
- private static final String TOR_PROXY_ADDRESS = "127.0.0.1";
|
32
|
|
- private static final int TOR_SOCKS_PROXY_PORT = 9150;
|
33
|
|
- private static final int TOR_HTTP_PROXY_PORT = 8218;
|
34
|
|
-
|
35
|
31
|
public static URLConnection openConnectionWithProxy(final URI uri) throws IOException {
|
36
|
|
- final java.net.ProxySelector ps = java.net.ProxySelector.getDefault();
|
37
|
|
- Proxy proxy = Proxy.NO_PROXY;
|
38
|
|
- if (ps != null) {
|
39
|
|
- final List<Proxy> proxies = ps.select(uri);
|
40
|
|
- if (proxies != null && !proxies.isEmpty()) {
|
41
|
|
- proxy = proxies.get(0);
|
42
|
|
- }
|
43
|
|
- }
|
44
|
|
-
|
45
|
|
- /* Ignore the proxy we found from the VM, only use Tor. We can probably
|
46
|
|
- * safely use the logic in this class in the future. */
|
47
|
|
- return uri.toURL().openConnection(getProxy());
|
48
|
|
- }
|
49
|
|
-
|
50
|
|
- public static Proxy getProxy() {
|
51
|
|
- // TODO make configurable
|
52
|
|
- return new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(TOR_PROXY_ADDRESS, TOR_SOCKS_PROXY_PORT));
|
53
|
|
- }
|
54
|
|
-
|
55
|
|
- public static String getProxyHostAddress() {
|
56
|
|
- return TOR_PROXY_ADDRESS;
|
57
|
|
- }
|
58
|
|
-
|
59
|
|
- public static int getSocksProxyPort() {
|
60
|
|
- return TOR_SOCKS_PROXY_PORT;
|
61
|
|
- }
|
62
|
|
-
|
63
|
|
- public static int getHttpProxyPort() {
|
64
|
|
- return TOR_HTTP_PROXY_PORT;
|
|
32
|
+// tb-42660: This should not be used: it cannot safely get tor configs so would be a proxy leak risk
|
|
33
|
+ throw new IOException("openConnectionWithProxy disabled by tb-42660");
|
|
34
|
+// final java.net.ProxySelector ps = java.net.ProxySelector.getDefault();
|
|
35
|
+// Proxy proxy = Proxy.NO_PROXY;
|
|
36
|
+// if (ps != null) {
|
|
37
|
+// final List<Proxy> proxies = ps.select(uri);
|
|
38
|
+// if (proxies != null && !proxies.isEmpty()) {
|
|
39
|
+// proxy = proxies.get(0);
|
|
40
|
+// }
|
|
41
|
+// }
|
|
42
|
+//
|
|
43
|
+// return uri.toURL().openConnection(proxy);
|
65
|
44
|
}
|
66
|
45
|
|
67
|
46
|
public ProxySelector() {}
|