use socks instead of http proxy for http upload
http proxy doesn’t seem to work with onion v3
This commit is contained in:
parent
997f922401
commit
953307ca30
|
@ -36,7 +36,7 @@ public class HttpConnectionManager extends AbstractConnectionManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Proxy getProxy() throws IOException {
|
public static Proxy getProxy() throws IOException {
|
||||||
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), 8118));
|
return new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), 9050));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createNewDownloadConnection(Message message) {
|
public void createNewDownloadConnection(Message message) {
|
||||||
|
|
|
@ -276,7 +276,9 @@ public class HttpDownloadConnection implements Transferable {
|
||||||
Log.d(Config.LOGTAG, "retrieve file size. interactive:" + String.valueOf(interactive));
|
Log.d(Config.LOGTAG, "retrieve file size. interactive:" + String.valueOf(interactive));
|
||||||
changeStatus(STATUS_CHECKING);
|
changeStatus(STATUS_CHECKING);
|
||||||
HttpURLConnection connection;
|
HttpURLConnection connection;
|
||||||
if (mUseTor || message.getConversation().getAccount().isOnion()) {
|
final String hostname = mUrl.getHost();
|
||||||
|
final boolean onion = hostname != null && hostname.endsWith(".onion");
|
||||||
|
if (mUseTor || message.getConversation().getAccount().isOnion() || onion) {
|
||||||
connection = (HttpURLConnection) mUrl.openConnection(HttpConnectionManager.getProxy());
|
connection = (HttpURLConnection) mUrl.openConnection(HttpConnectionManager.getProxy());
|
||||||
} else {
|
} else {
|
||||||
connection = (HttpURLConnection) mUrl.openConnection();
|
connection = (HttpURLConnection) mUrl.openConnection();
|
||||||
|
|
|
@ -155,11 +155,14 @@ public class HttpUploadConnection implements Transferable {
|
||||||
PowerManager.WakeLock wakeLock = mHttpConnectionManager.createWakeLock("http_upload_"+message.getUuid());
|
PowerManager.WakeLock wakeLock = mHttpConnectionManager.createWakeLock("http_upload_"+message.getUuid());
|
||||||
try {
|
try {
|
||||||
fileInputStream = new FileInputStream(file);
|
fileInputStream = new FileInputStream(file);
|
||||||
|
final String slotHostname = slot.getPutUrl().getHost();
|
||||||
|
final boolean onionSlot = slotHostname != null && slotHostname.endsWith(".onion");
|
||||||
final int expectedFileSize = (int) file.getExpectedSize();
|
final int expectedFileSize = (int) file.getExpectedSize();
|
||||||
final int readTimeout = (expectedFileSize / 2048) + Config.SOCKET_TIMEOUT; //assuming a minimum transfer speed of 16kbit/s
|
final int readTimeout = (expectedFileSize / 2048) + Config.SOCKET_TIMEOUT; //assuming a minimum transfer speed of 16kbit/s
|
||||||
wakeLock.acquire(readTimeout);
|
wakeLock.acquire(readTimeout);
|
||||||
Log.d(Config.LOGTAG, "uploading to " + slot.getPutUrl().toString()+ " w/ read timeout of "+readTimeout+"s");
|
Log.d(Config.LOGTAG, "uploading to " + slot.getPutUrl().toString()+ " w/ read timeout of "+readTimeout+"s");
|
||||||
if (mUseTor || message.getConversation().getAccount().isOnion()) {
|
|
||||||
|
if (mUseTor || message.getConversation().getAccount().isOnion() || onionSlot) {
|
||||||
connection = (HttpURLConnection) slot.getPutUrl().openConnection(HttpConnectionManager.getProxy());
|
connection = (HttpURLConnection) slot.getPutUrl().openConnection(HttpConnectionManager.getProxy());
|
||||||
} else {
|
} else {
|
||||||
connection = (HttpURLConnection) slot.getPutUrl().openConnection();
|
connection = (HttpURLConnection) slot.getPutUrl().openConnection();
|
||||||
|
|
Loading…
Reference in New Issue