run nodejs in non-root user
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
package com.github.shadowsocks;
|
||||
|
||||
public class Node {
|
||||
static {
|
||||
System.loadLibrary("node");
|
||||
}
|
||||
public static native void exec(String cmd);
|
||||
}
|
||||
@@ -103,7 +103,6 @@ public class Shadowsocks extends PreferenceActivity implements
|
||||
|
||||
private static ProgressDialog mProgressDialog = null;
|
||||
|
||||
private CheckBoxPreference isAutoConnectCheck;
|
||||
private CheckBoxPreference isGlobalProxyCheck;
|
||||
private EditTextPreference proxyText;
|
||||
private EditTextPreference portText;
|
||||
@@ -169,7 +168,6 @@ public class Shadowsocks extends PreferenceActivity implements
|
||||
isGFWListCheck.setEnabled(false);
|
||||
isBypassAppsCheck.setEnabled(false);
|
||||
|
||||
isAutoConnectCheck.setEnabled(false);
|
||||
isGlobalProxyCheck.setEnabled(false);
|
||||
}
|
||||
|
||||
@@ -185,7 +183,6 @@ public class Shadowsocks extends PreferenceActivity implements
|
||||
isBypassAppsCheck.setEnabled(true);
|
||||
}
|
||||
|
||||
isAutoConnectCheck.setEnabled(true);
|
||||
}
|
||||
|
||||
private boolean isTextEmpty(String s, String msg) {
|
||||
@@ -213,7 +210,6 @@ public class Shadowsocks extends PreferenceActivity implements
|
||||
proxyedApps = findPreference("proxyedApps");
|
||||
|
||||
isRunningCheck = (CheckBoxPreference) findPreference("isRunning");
|
||||
isAutoConnectCheck = (CheckBoxPreference) findPreference("isAutoConnect");
|
||||
isGlobalProxyCheck = (CheckBoxPreference) findPreference("isGlobalProxy");
|
||||
isGFWListCheck = (CheckBoxPreference) findPreference("isGFWList");
|
||||
isBypassAppsCheck = (CheckBoxPreference) findPreference("isBypassApps");
|
||||
|
||||
@@ -57,6 +57,7 @@ import android.util.Log;
|
||||
import com.google.analytics.tracking.android.EasyTracker;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
@@ -183,10 +184,15 @@ public class ShadowsocksService extends Service {
|
||||
}
|
||||
|
||||
public void startShadowsocksDaemon() {
|
||||
final String cmd = String.format("nohup " + BASE
|
||||
+ "node " + BASE + "local.js -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\" &",
|
||||
appHost, remotePort, port, sitekey);
|
||||
Utils.runRootCommand(cmd);
|
||||
new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
final String cmd = String.format(BASE
|
||||
+ "node " + BASE + "local.js -s \"%s\" -p \"%d\" -l \"%d\" -k \"%s\"",
|
||||
appHost, remotePort, port, sitekey);
|
||||
Node.exec(cmd);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
public void startDnsDaemon() {
|
||||
|
||||
Reference in New Issue
Block a user