small fixes to VPN service port setup to ensure proper setup

This commit is contained in:
Nathan Freitas 2016-01-25 23:44:44 -05:00
parent d58555a358
commit da7eb961f1
3 changed files with 21 additions and 24 deletions

View File

@ -568,11 +568,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
}
}).start();
if (OrbotVpnService.mSocksProxyPort == -1)
OrbotVpnService.mSocksProxyPort = (int)((Math.random()*1000)+10000);
}
catch (Exception e)
{
@ -752,7 +748,7 @@ 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.mSocksProxyPort);
customEnv.add("TOR_PT_PROXY=socks5://127.0.0.1:" + OrbotVpnService.sSocksProxyServerPort);
String baseDirectory = OrbotApp.fileTor.getParent();
Shell shellUser = Shell.startShell(customEnv, baseDirectory);
@ -1208,9 +1204,6 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
intent.putExtra("torSocks", mPortSOCKS);
if (!mIsLollipop)
intent.putExtra("proxyPort",OrbotVpnService.mSocksProxyPort);
startService(intent);
}
@ -1899,7 +1892,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
{
String proxyType = "socks5";
String proxyHost = "127.0.0.1";
extraLines.append(proxyType + "Proxy" + ' ' + proxyHost + ':' + OrbotVpnService.mSocksProxyPort).append('\n');
extraLines.append(proxyType + "Proxy" + ' ' + proxyHost + ':' + OrbotVpnService.sSocksProxyServerPort).append('\n');
};
}
@ -1987,14 +1980,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
String bridgeConfig = "meek exec " + OrbotApp.fileMeekclient.getCanonicalPath();
extraLines.append("ClientTransportPlugin" + ' ' + bridgeConfig).append('\n');
String[] meekBridge =
{
"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"
};
int meekIdx = 2; //let's use Azure by default
if (bridgeList != null && bridgeList.length() == 1)
@ -2003,7 +1989,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
{
meekIdx = Integer.parseInt(bridgeList);
if (meekIdx+1 > meekBridge.length)
if (meekIdx+1 > BRIDGES_MEEK.length)
throw new Exception("not valid meek idx");
}
catch (Exception e)
@ -2012,7 +1998,7 @@ public class TorService extends Service implements TorServiceConstants, OrbotCon
}
}
extraLines.append("Bridge " + meekBridge[meekIdx]).append('\n');
extraLines.append("Bridge " + BRIDGES_MEEK[meekIdx]).append('\n');
}

View File

@ -152,5 +152,12 @@ public interface TorServiceConstants {
//EXIT COUNTRY CODES
public final static String[] COUNTRY_CODES = {"DE","AT","SE","CH","IS","CA","US","ES","FR","BG","PL","AU","BR","CZ","DK","FI","GB","HU","NL","JP","RO","RU","SG","SK"};
//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"
};
}

View File

@ -67,7 +67,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private int mTorSocks = TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT;
public static int mSocksProxyPort = -1;
public static int sSocksProxyServerPort = -1;
private ProxyServer mSocksProxyServer;
@ -100,7 +100,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
Log.d(TAG,"starting OrbotVPNService service!");
mTorSocks = intent.getIntExtra("torSocks", TorServiceConstants.SOCKS_PROXY_PORT_DEFAULT);
mSocksProxyPort = intent.getIntExtra("proxyPort", 0);
// The handler is only used to show messages.
if (mHandler == null) {
@ -109,6 +108,11 @@ 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();
}
@ -156,7 +160,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
{
mSocksProxyServer = new ProxyServer(new ServerAuthenticatorNone(null, null));
ProxyServer.setVpnService(OrbotVpnService.this);
mSocksProxyServer.start(mSocksProxyPort, 5, InetAddress.getLocalHost());
mSocksProxyServer.start(sSocksProxyServerPort, 5, InetAddress.getLocalHost());
}
catch (Exception e)