summaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorcyBerta <cyberta@riseup.net>2019-06-12 17:39:14 +0200
committercyBerta <cyberta@riseup.net>2019-08-02 01:49:37 +0200
commit04df0d72d5f085a60e3b75b1b7df6244f04940f0 (patch)
treea9a735bc6406475db0b6938a492cbe272d72d4e4 /app/src/main
parent0322a53ca28a96ecbf20b1f63e99b8b31f201316 (diff)
define local port to run shapeshifter-dispatcher on startup, fix pid lookup, quick fix architecture for arm
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Dispatcher.java38
1 files changed, 8 insertions, 30 deletions
diff --git a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Dispatcher.java b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Dispatcher.java
index ac846fd9..05ce2256 100644
--- a/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Dispatcher.java
+++ b/app/src/main/java/se/leap/bitmaskclient/pluggableTransports/Dispatcher.java
@@ -24,6 +24,7 @@ import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
+import java.util.NoSuchElementException;
import java.util.StringTokenizer;
@@ -33,6 +34,7 @@ import java.util.StringTokenizer;
public class Dispatcher {
private static final String ASSET_KEY = "piedispatcher";
+ private static final String DISPATCHER_PORT = "4430";
private static final String TAG = Dispatcher.class.getName();
private final String remoteIP;
private final String remotePort;
@@ -40,7 +42,6 @@ public class Dispatcher {
private final String iatMode;
private File fileDispatcher;
private Context context;
- private String port = "";
private Thread dispatcherThread = null;
private int dipatcherPid = -1;
@@ -68,8 +69,10 @@ public class Dispatcher {
" -target " + remoteIP + ":" + remotePort +
" -transports obfs4" +
" -options \"" + String.format("{\\\"cert\\\": \\\"%s\\\", \\\"iatMode\\\": \\\"%s\\\"}\"", certificate, iatMode) +
- " -logLevel DEBUG -enableLogging";
+ " -logLevel DEBUG -enableLogging" +
+ " -proxylistenaddr 127.0.0.1:" + DISPATCHER_PORT;
+ Log.d(TAG, "dispatcher command: " + dispatcherCommand);
runBlockingCmd(new String[]{dispatcherCommand}, dispatcherLog);
} catch (IOException e) {
e.printStackTrace();
@@ -81,37 +84,12 @@ public class Dispatcher {
// get pid of dispatcher
StringBuilder log = new StringBuilder();
- String pidCommand = "ps | grep " + fileDispatcher.getCanonicalPath();
+ String pidCommand = "ps | grep piedispatcher";
runBlockingCmd(new String[]{pidCommand}, log);
String output = log.toString();
StringTokenizer st = new StringTokenizer(output, " ");
st.nextToken(); // proc owner
dipatcherPid = Integer.parseInt(st.nextToken().trim());
-
- // get open port of dispatcher
- String getPortCommand = "cat " + context.getFilesDir().getCanonicalPath() + "/state/dispatcher.log | grep \"obfs4 - registered listener\"";
- long timeout = System.currentTimeMillis() + 5000;
- int i = 1;
- while (this.port.length() == 0 && System.currentTimeMillis() < timeout) {
- log = new StringBuilder();
- Log.d(TAG, i + ". try to get port");
- runBlockingCmd(new String[]{getPortCommand}, log);
- output = log.toString();
- if (output.length() > 0) {
- Log.d(TAG, "dispatcher log: \n =================\n" + output);
- }
-
- String dispatcherLog[] = output.split(" ");
- if (dispatcherLog.length > 0) {
- String localAddressAndPort = dispatcherLog[dispatcherLog.length - 1];
- if (localAddressAndPort.contains(":")) {
- this.port = localAddressAndPort.split(":")[1].replace(System.getProperty("line.separator"), "");
- Log.d(TAG, "local port is: " + this.port);
- }
- }
- i += 1;
- }
-
} catch(Exception e){
if (dispatcherThread.isAlive()) {
Log.e(TAG, e.getMessage() + ". Shutting down Dispatcher thread.");
@@ -121,7 +99,7 @@ public class Dispatcher {
}
public String getPort() {
- return port;
+ return DISPATCHER_PORT;
}
public void stop() {
@@ -151,7 +129,7 @@ public class Dispatcher {
String arch = System.getProperty("os.arch");
if (arch.contains("arm"))
- arch = "arm";
+ arch = "armeabi-v7a";
else
arch = "x86";