use http proxy below android 7.1

This commit is contained in:
Daniel Gultsch 2021-03-22 18:03:25 +01:00
parent 02b16063c6
commit 914ea9c398

View file

@ -1,5 +1,6 @@
package eu.siacs.conversations.http; package eu.siacs.conversations.http;
import android.os.Build;
import android.util.Log; import android.util.Log;
import org.apache.http.conn.ssl.StrictHostnameVerifier; import org.apache.http.conn.ssl.StrictHostnameVerifier;
@ -45,10 +46,16 @@ public class HttpConnectionManager extends AbstractConnectionManager {
} }
public static Proxy getProxy() { public static Proxy getProxy() {
final InetAddress localhost;
try { try {
return new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(InetAddress.getByAddress(new byte[]{127, 0, 0, 1}), 9050)); localhost = InetAddress.getByAddress(new byte[]{127, 0, 0, 1});
} catch (final UnknownHostException e) { } catch (final UnknownHostException e) {
throw new IllegalStateException(e); throw new IllegalStateException(e);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
return new Proxy(Proxy.Type.SOCKS, new InetSocketAddress(localhost, 9050));
} else {
return new Proxy(Proxy.Type.HTTP, new InetSocketAddress(localhost, 8118));
} }
} }