fixed Proxy generation, proxy working for for cloud import
This commit is contained in:
@@ -34,13 +34,11 @@ public class ParcelableProxy implements Parcelable {
|
||||
private final int TYPE_HTTP = 1;
|
||||
private final int TYPE_SOCKS = 2;
|
||||
|
||||
public ParcelableProxy(Proxy proxy) {
|
||||
InetSocketAddress address = (InetSocketAddress) proxy.address();
|
||||
public ParcelableProxy(String hostName, int port, Proxy.Type type) {
|
||||
mProxyHost = hostName;
|
||||
mProxyPort = port;
|
||||
|
||||
mProxyHost = address.getHostName();
|
||||
mProxyPort = address.getPort();
|
||||
|
||||
switch (proxy.type()) {
|
||||
switch (type) {
|
||||
case HTTP: {
|
||||
mProxyType = TYPE_HTTP;
|
||||
break;
|
||||
|
||||
@@ -310,23 +310,22 @@ public class Preferences {
|
||||
}
|
||||
|
||||
public ProxyPrefs getProxyPrefs() {
|
||||
Proxy proxy = null;
|
||||
boolean useTor = getUseTorProxy();
|
||||
boolean useNormalProxy = getUseNormalProxy();
|
||||
|
||||
if (useTor) {
|
||||
proxy = new Proxy(Constants.Orbot.PROXY_TYPE,
|
||||
new InetSocketAddress(Constants.Orbot.PROXY_HOST, Constants.Orbot.PROXY_PORT));
|
||||
return new ProxyPrefs(true, false, Constants.Orbot.PROXY_HOST, Constants.Orbot.PROXY_PORT,
|
||||
Constants.Orbot.PROXY_TYPE);
|
||||
}
|
||||
else if (useNormalProxy) {
|
||||
proxy = new Proxy(getProxyType(), new InetSocketAddress(getProxyHost(), getProxyPort()));
|
||||
return new ProxyPrefs(useTor, useNormalProxy, getProxyHost(), getProxyPort(), getProxyType());
|
||||
} else {
|
||||
return new ProxyPrefs(false, false, null, -1, null);
|
||||
}
|
||||
|
||||
return new ProxyPrefs(getUseTorProxy(), getUseNormalProxy(), proxy);
|
||||
}
|
||||
|
||||
public static class ProxyPrefs {
|
||||
public final Proxy proxy;
|
||||
public final ParcelableProxy parcelableProxy;
|
||||
public final boolean torEnabled;
|
||||
public final boolean normalPorxyEnabled;
|
||||
|
||||
@@ -335,12 +334,12 @@ public class Preferences {
|
||||
*
|
||||
* @param torEnabled if Tor is to be used
|
||||
* @param normalPorxyEnabled if user-specified proxy is to be used
|
||||
* @param proxy proxy to use, leave null if none
|
||||
*/
|
||||
public ProxyPrefs(boolean torEnabled, boolean normalPorxyEnabled, Proxy proxy) {
|
||||
public ProxyPrefs(boolean torEnabled, boolean normalPorxyEnabled, String hostName, int port, Proxy.Type type) {
|
||||
this.torEnabled = torEnabled;
|
||||
this.normalPorxyEnabled = normalPorxyEnabled;
|
||||
this.proxy = proxy;
|
||||
if(!torEnabled && !normalPorxyEnabled) this.parcelableProxy = null;
|
||||
else this.parcelableProxy = new ParcelableProxy(hostName, port, type);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user