move to using meek_lite mode from obfs4client and update/improve proxying code
This commit is contained in:
parent
66a5b7ad26
commit
57855932f4
|
@ -28,7 +28,7 @@ public class OrbotApp extends Application implements OrbotConstants
|
|||
public static File fileTor;
|
||||
public static File filePolipo;
|
||||
public static File fileObfsclient;
|
||||
public static File fileMeekclient;
|
||||
// public static File fileMeekclient;
|
||||
public static File fileXtables;
|
||||
public static File fileTorRc;
|
||||
public static File filePdnsd;
|
||||
|
@ -48,13 +48,10 @@ public class OrbotApp extends Application implements OrbotConstants
|
|||
fileTor= new File(appBinHome, TorServiceConstants.TOR_ASSET_KEY);
|
||||
filePolipo = new File(appBinHome, TorServiceConstants.POLIPO_ASSET_KEY);
|
||||
fileObfsclient = new File(appBinHome, TorServiceConstants.OBFSCLIENT_ASSET_KEY);
|
||||
fileMeekclient = new File(appBinHome, TorServiceConstants.MEEK_ASSET_KEY);
|
||||
fileXtables = new File(appBinHome, TorServiceConstants.IPTABLES_ASSET_KEY);
|
||||
fileTorRc = new File(appBinHome, TorServiceConstants.TORRC_ASSET_KEY);
|
||||
filePdnsd = new File(appBinHome, TorServiceConstants.PDNSD_ASSET_KEY);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -100,12 +100,13 @@ public class TorResourceInstaller implements TorServiceConstants {
|
|||
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||
streamToFile(is,outFile, false, true);
|
||||
setExecutable(outFile);
|
||||
|
||||
/**
|
||||
is = context.getAssets().open(cpuPath + "/" + MEEK_ASSET_KEY + MP3_EXT);
|
||||
outFile = new File(installFolder, MEEK_ASSET_KEY);
|
||||
shell.add(new SimpleCommand(COMMAND_RM_FORCE + outFile.getAbsolutePath())).waitForFinish();
|
||||
streamToFile(is,outFile, false, true);
|
||||
setExecutable(outFile);
|
||||
*/
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,7 @@ import java.io.InputStream;
|
|||
import java.io.InputStreamReader;
|
||||
import java.io.PrintStream;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.Socket;
|
||||
|
@ -482,25 +483,30 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
|||
try {
|
||||
TorServiceUtils.killProcess(OrbotApp.fileObfsclient);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
// e.printStackTrace();
|
||||
Log.w(TAG,"could not kill obfsclient",e);
|
||||
cannotKillFile = OrbotApp.fileObfsclient;
|
||||
}
|
||||
|
||||
/**
|
||||
try {
|
||||
TorServiceUtils.killProcess(OrbotApp.fileMeekclient);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
cannotKillFile = OrbotApp.fileMeekclient;
|
||||
}
|
||||
*/
|
||||
|
||||
try {
|
||||
TorServiceUtils.killProcess(OrbotApp.filePolipo);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.w(TAG,"could not kill polipo",e);
|
||||
cannotKillFile = OrbotApp.filePolipo;
|
||||
}
|
||||
try {
|
||||
TorServiceUtils.killProcess(OrbotApp.fileTor);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
Log.w(TAG,"could not kill tor",e);
|
||||
cannotKillFile = OrbotApp.fileTor;
|
||||
}
|
||||
}
|
||||
|
@ -743,7 +749,9 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
|||
|
||||
if (Prefs.bridgesEnabled())
|
||||
if (Prefs.useVpn() && !mIsLollipop)
|
||||
customEnv.add("TOR_PT_PROXY=socks5://127.0.0.1:" + OrbotVpnService.sSocksProxyServerPort);
|
||||
{
|
||||
customEnv.add("TOR_PT_PROXY=socks5://" + OrbotVpnService.sSocksProxyLocalhost + ":" + OrbotVpnService.sSocksProxyServerPort);
|
||||
}
|
||||
|
||||
String baseDirectory = OrbotApp.fileTor.getParent();
|
||||
Shell shellUser = Shell.startShell(customEnv, baseDirectory);
|
||||
|
@ -1658,7 +1666,9 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
|||
|
||||
}
|
||||
catch (Exception ioe){
|
||||
|
||||
debug("error requesting newnym: " + ioe.getLocalizedMessage());
|
||||
|
||||
}
|
||||
}
|
||||
}.start();
|
||||
|
@ -1885,8 +1895,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
|||
if (!mIsLollipop)
|
||||
{
|
||||
String proxyType = "socks5";
|
||||
String proxyHost = "127.0.0.1";
|
||||
extraLines.append(proxyType + "Proxy" + ' ' + proxyHost + ':' + OrbotVpnService.sSocksProxyServerPort).append('\n');
|
||||
extraLines.append(proxyType + "Proxy" + ' ' + OrbotVpnService.sSocksProxyLocalhost + ':' + OrbotVpnService.sSocksProxyServerPort).append('\n');
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1936,7 +1945,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
|||
{
|
||||
|
||||
//check if any PT bridges are needed
|
||||
boolean obfsBridges = bridgeList.contains("obfs3")||bridgeList.contains("obfs4")||bridgeList.contains("scramblesuit");
|
||||
boolean obfsBridges = bridgeList.contains("obfs3")||bridgeList.contains("obfs4")||bridgeList.contains("scramblesuit")||bridgeList.contains("meek");
|
||||
|
||||
if (obfsBridges)
|
||||
{
|
||||
|
@ -1972,7 +1981,9 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
|
|||
|
||||
debug ("Using meek bridges");
|
||||
|
||||
String bridgeConfig = "meek exec " + OrbotApp.fileMeekclient.getCanonicalPath();
|
||||
// String bridgeConfig = "meek exec " + OrbotApp.fileMeekclient.getCanonicalPath();
|
||||
String bridgeConfig = "meek_lite exec " + OrbotApp.fileObfsclient.getCanonicalPath();
|
||||
|
||||
extraLines.append("ClientTransportPlugin" + ' ' + bridgeConfig).append('\n');
|
||||
|
||||
int meekIdx = 2; //let's use Azure by default
|
||||
|
|
|
@ -141,7 +141,7 @@ public interface TorServiceConstants {
|
|||
//obfsproxy
|
||||
public static final String OBFSCLIENT_ASSET_KEY = "obfs4proxy";
|
||||
|
||||
public static final String MEEK_ASSET_KEY = "meek-client";
|
||||
// public static final String MEEK_ASSET_KEY = "meek-client";
|
||||
|
||||
//name of the iptables binary
|
||||
public final static String IPTABLES_ASSET_KEY = "xtables";
|
||||
|
@ -155,9 +155,9 @@ public interface TorServiceConstants {
|
|||
//MEEK BRIDGEs
|
||||
public final static String[] BRIDGES_MEEK =
|
||||
{
|
||||
"meek 0.0.2.0:1 url=https://meek-reflect.appspot.com/ front=www.google.com",
|
||||
"meek 0.0.2.0:2 url=https://d2zfqthxsdq309.cloudfront.net/ front=a0.awsstatic.com",
|
||||
"meek 0.0.2.0:3 url=https://az668014.vo.msecnd.net/ front=ajax.aspnetcdn.com"
|
||||
"meek_lite 0.0.2.0:1 url=https://meek-reflect.appspot.com/ front=www.google.com",
|
||||
"meek_lite 0.0.2.0:2 url=https://d2zfqthxsdq309.cloudfront.net/ front=a0.awsstatic.com",
|
||||
"meek_lite 0.0.2.0:3 url=https://az668014.vo.msecnd.net/ front=ajax.aspnetcdn.com"
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -178,12 +178,12 @@ public class TorServiceUtils implements TorServiceConstants {
|
|||
}
|
||||
|
||||
catch(ConnectException ce){
|
||||
ce.printStackTrace();
|
||||
//ce.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
//ex.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.FileOutputStream;
|
|||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
import java.util.concurrent.TimeoutException;
|
||||
|
@ -68,6 +69,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
|||
private int mTorSocks = TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT;
|
||||
|
||||
public static int sSocksProxyServerPort = -1;
|
||||
public static String sSocksProxyLocalhost = null;
|
||||
private ProxyServer mSocksProxyServer;
|
||||
|
||||
|
||||
|
@ -109,10 +111,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
|||
if (!mIsLollipop)
|
||||
{
|
||||
|
||||
//generate the proxy port that the
|
||||
if (sSocksProxyServerPort == -1)
|
||||
sSocksProxyServerPort = (int)((Math.random()*1000)+10000);
|
||||
|
||||
startSocksBypass();
|
||||
}
|
||||
|
||||
|
@ -151,6 +149,24 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
|||
|
||||
public void run ()
|
||||
{
|
||||
|
||||
//generate the proxy port that the
|
||||
if (sSocksProxyServerPort == -1)
|
||||
{
|
||||
try {
|
||||
|
||||
sSocksProxyLocalhost = "127.0.0.1";// InetAddress.getLocalHost().getHostAddress();
|
||||
sSocksProxyServerPort = (int)((Math.random()*1000)+10000);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.e(TAG,"Unable to access localhost",e);
|
||||
throw new RuntimeException("Unable to access localhost: " + e);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (mSocksProxyServer != null)
|
||||
{
|
||||
stopSocksBypass ();
|
||||
|
@ -274,7 +290,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
|||
//start PDNSD daemon pointing to OpenDNS
|
||||
startDNS(DEFAULT_ACTUAL_DNS,53);
|
||||
|
||||
|
||||
final String vpnName = "OrbotVPN";
|
||||
final String localhost = "127.0.0.1";
|
||||
|
||||
|
@ -392,8 +407,10 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
|
|||
" -c " + baseDirectory + "/pdnsd.conf";
|
||||
|
||||
SimpleCommand shellCommand = new SimpleCommand(cmdString);
|
||||
|
||||
shell.add(shellCommand).waitForFinish();
|
||||
|
||||
Log.i(TAG,"PDNSD: " + shellCommand.getExitCode() + ": " + shellCommand.getOutput());
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue