commit d63d10d8aeaebe767c2a43c7a81fab97fafb8a2a Author: Nathan Freitas nathan@freitas.net Date: Mon Feb 2 14:01:08 2015 -0500
massive cleanup of merged code from Ony fork removal/comment out of LoggerFactory log system --- project.properties | 1 + src/com/runjva/sourceforge/jsocks/main/SOCKS.java | 6 +- .../sourceforge/jsocks/protocol/ProxyServer.java | 65 ++- .../jsocks/protocol/Socks5DatagramSocket.java | 13 +- .../sourceforge/jsocks/protocol/Socks5Message.java | 8 +- .../sourceforge/jsocks/protocol/SocksSocket.java | 7 +- .../jsocks/protocol/UDPRelayServer.java | 19 +- .../runjva/sourceforge/jsocks/server/Ident.java | 7 +- src/org/torproject/android/OrbotMainActivity.java | 514 +------------------- .../android/service/TorResourceInstaller.java | 3 +- src/org/torproject/android/service/TorService.java | 26 +- .../torproject/android/settings/AppManager.java | 12 +- .../android/settings/SettingsPreferences.java | 3 +- .../android/ui/ChooseLocaleWizardActivity.java | 3 +- src/org/torproject/android/ui/LotsaText.java | 2 +- .../android/ui/OrbotDiagnosticsActivity.java | 5 - .../torproject/android/vpn/OrbotVpnService.java | 17 +- 17 files changed, 83 insertions(+), 628 deletions(-)
diff --git a/project.properties b/project.properties index e87ce9f..7f2e988 100644 --- a/project.properties +++ b/project.properties @@ -13,3 +13,4 @@ target=android-21 android.library.reference.1=external/appcompat android.library.reference.2=external/superuser-commands/RootCommands-Library android.library.reference.3=../Orweb +android.library.reference.4=../OnionKit/libnetcipher diff --git a/src/com/runjva/sourceforge/jsocks/main/SOCKS.java b/src/com/runjva/sourceforge/jsocks/main/SOCKS.java index 9135f87..45eb866 100644 --- a/src/com/runjva/sourceforge/jsocks/main/SOCKS.java +++ b/src/com/runjva/sourceforge/jsocks/main/SOCKS.java @@ -9,9 +9,6 @@ import java.util.Hashtable; import java.util.Properties; import java.util.StringTokenizer;
-import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.runjva.sourceforge.jsocks.protocol.InetRange; import com.runjva.sourceforge.jsocks.protocol.ProxyServer; import com.runjva.sourceforge.jsocks.protocol.SocksProxyBase; @@ -20,7 +17,6 @@ import com.runjva.sourceforge.jsocks.server.IdentAuthenticator; public class SOCKS {
private static final int DEFAULT_LISTENING_PORT = 1080; - final private static Logger log = LoggerFactory.getLogger(SOCKS.class);
static public void usage() { System.out.println("Usage: java SOCKS [inifile1 inifile2 ...]\n" @@ -258,7 +254,7 @@ public class SOCKS { // /////////////////
static void inform(String s) { - log.info(s); + // log.info(s); }
static void exit(String msg) { diff --git a/src/com/runjva/sourceforge/jsocks/protocol/ProxyServer.java b/src/com/runjva/sourceforge/jsocks/protocol/ProxyServer.java index a672bfa..739feb8 100644 --- a/src/com/runjva/sourceforge/jsocks/protocol/ProxyServer.java +++ b/src/com/runjva/sourceforge/jsocks/protocol/ProxyServer.java @@ -15,9 +15,7 @@ import java.net.Socket; import java.net.SocketAddress; import java.nio.channels.SocketChannel;
-import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - +import android.annotation.SuppressLint; import android.net.VpnService;
import com.runjva.sourceforge.jsocks.server.ServerAuthenticator; @@ -60,7 +58,6 @@ public class ProxyServer implements Runnable { static int iddleTimeout = 180000; // 3 minutes static int acceptTimeout = 180000; // 3 minutes
- static Logger log = LoggerFactory.getLogger(ProxyServer.class); static SocksProxyBase proxy;
static VpnService vpnService; @@ -181,13 +178,13 @@ public class ProxyServer implements Runnable { ss = new ServerSocket(port, backlog, localIP); final String address = ss.getInetAddress().getHostAddress(); final int localPort = ss.getLocalPort(); - log.info("Starting SOCKS Proxy on: {}:{}", address, localPort); + debug("Starting SOCKS Proxy on: {}:{}", address, localPort);
while (true) { final Socket s = ss.accept(); final String hostName = s.getInetAddress().getHostName(); final int port2 = s.getPort(); - log.info("Accepted from:{}:{}", hostName, port2); + debug("Accepted from:{}:{}", hostName, port2);
final ProxyServer ps = new ProxyServer(auth, s); (new Thread(ps)).start(); @@ -226,7 +223,7 @@ public class ProxyServer implements Runnable { if (auth != null) { auth.endSession(); } - log.info("Main thread(client->remote)stopped."); + debug("Main thread(client->remote)stopped."); } break; case ACCEPT_MODE: @@ -242,7 +239,7 @@ public class ProxyServer implements Runnable { handleException(ioe); } finally { abort(); - log.info("Accept thread(remote->client) stopped"); + debug("Accept thread(remote->client) stopped"); } break; case PIPE_MODE: @@ -251,13 +248,13 @@ public class ProxyServer implements Runnable { } catch (final IOException ioe) { } finally { abort(); - log.info("Support thread(remote->client) stopped"); + debug("Support thread(remote->client) stopped"); } break; case ABORT_MODE: break; default: - log.warn("Unexpected MODE " + mode); + debug("Unexpected MODE " + mode); } }
@@ -269,13 +266,13 @@ public class ProxyServer implements Runnable { try { auth = auth.startSession(sock); } catch (final IOException ioe) { - log.warn("Auth throwed exception:", ioe); + debug("Auth throwed exception:", ioe); auth = null; return; }
if (auth == null) { // Authentication failed - log.info("Authentication failed"); + debug("Authentication failed"); return; }
@@ -350,6 +347,7 @@ public class ProxyServer implements Runnable { sendErrorMessage(error_code); }
+ @SuppressLint("NewApi") private void onConnect(final ProxyMessage msg) throws IOException { Socket s;
@@ -370,7 +368,7 @@ public class ProxyServer implements Runnable { if (vpnService != null) vpnService.protect(s); - log.info("Connected to " + s.getInetAddress() + ":" + s.getPort()); + debug("Connected to " + s.getInetAddress() + ":" + s.getPort());
ProxyMessage response = null; final InetAddress localAddress = s.getLocalAddress(); @@ -401,7 +399,7 @@ public class ProxyServer implements Runnable {
final InetAddress inetAddress = ss.getInetAddress(); final int localPort = ss.getLocalPort(); - log.info("Trying accept on {}:{}", inetAddress, localPort); + debug("Trying accept on {}:{}", inetAddress, localPort);
if (msg.version == 5) { final int cmd = SocksProxyBase.SOCKS_SUCCESS; @@ -434,10 +432,10 @@ public class ProxyServer implements Runnable { } } } catch (final EOFException e) { - log.debug("Connection closed while we were trying to accept", e); + debug("Connection closed while we were trying to accept", e); return; } catch (final InterruptedIOException e) { - log.debug("Interrupted by unsucessful accept thread", e); + debug("Interrupted by unsucessful accept thread", e); if (mode != PIPE_MODE) { return; } @@ -459,7 +457,7 @@ public class ProxyServer implements Runnable { if (msg.ip.getHostAddress().equals("0.0.0.0")) { msg.ip = sock.getInetAddress(); } - log.info("Creating UDP relay server for {}:{}", msg.ip, msg.port); + debug("Creating UDP relay server for {}:{}", msg.ip, msg.port);
relayServer = new UDPRelayServer(msg.ip, msg.port, Thread.currentThread(), sock, auth); @@ -527,7 +525,7 @@ public class ProxyServer implements Runnable {
final InetAddress inetAddress = s.getInetAddress(); final int port = s.getPort(); - log.info("Accepted from {}:{}", s.getInetAddress(), port); + debug("Accepted from {}:{}", s.getInetAddress(), port);
ProxyMessage response;
@@ -597,7 +595,7 @@ public class ProxyServer implements Runnable { } mode = ABORT_MODE; try { - log.info("Aborting operation"); + debug("Aborting operation"); if (remote_sock != null) { remote_sock.close(); } @@ -621,11 +619,11 @@ public class ProxyServer implements Runnable { }
static final void log(final ProxyMessage msg) { - log.debug("Request version: {}, Command: ", msg.version, + debug("Request version: {}, Command: ", msg.version, command2String(msg.command));
final String user = msg.version == 4 ? ", User:" + msg.user : ""; - log.debug("IP:" + msg.ip + ", Port:" + msg.port + user); + debug("IP:" + msg.ip + ", Port:" + msg.port + user); }
private void pipe(final InputStream in, final OutputStream out) @@ -666,4 +664,29 @@ public class ProxyServer implements Runnable { return "Unknown Command " + cmd; } } + + public static void debug (String msg) + { + + } + + public static void debug (String msg, String host, int port) + { + + } + + public static void debug (String msg, Exception e) + { + + } + + public static void debug (String msg, InetAddress addr, int port) + { + + } + + public static void debug (String msg, int type, String log) + { + + } } diff --git a/src/com/runjva/sourceforge/jsocks/protocol/Socks5DatagramSocket.java b/src/com/runjva/sourceforge/jsocks/protocol/Socks5DatagramSocket.java index 6dcaf44..1b9da34 100644 --- a/src/com/runjva/sourceforge/jsocks/protocol/Socks5DatagramSocket.java +++ b/src/com/runjva/sourceforge/jsocks/protocol/Socks5DatagramSocket.java @@ -7,9 +7,6 @@ import java.net.DatagramPacket; import java.net.DatagramSocket; import java.net.InetAddress;
-import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Datagram socket to interract through the firewall.<BR> * Can be used same way as the normal DatagramSocket. One should be carefull @@ -44,8 +41,6 @@ public class Socks5DatagramSocket extends DatagramSocket { private boolean server_mode = false; UDPEncapsulation encapsulation;
- private Logger log = LoggerFactory.getLogger(Socks5DatagramSocket.class); - /** * Construct Datagram socket for communication over SOCKS5 proxy server. * This constructor uses default proxy, the one set with @@ -126,8 +121,8 @@ public class Socks5DatagramSocket extends DatagramSocket {
encapsulation = proxy.udp_encapsulation;
- log.debug("Datagram Socket:{}:{}", getLocalAddress(), getLocalPort()); - log.debug("Socks5Datagram: {}:{}", relayIP, relayPort); + // log.debug("Datagram Socket:{}:{}", getLocalAddress(), getLocalPort()); + // log.debug("Socks5Datagram: {}:{}", relayIP, relayPort); }
/** @@ -163,7 +158,7 @@ public class Socks5DatagramSocket extends DatagramSocket { // If the host should be accessed directly, send it as is. if (!server_mode && proxy.isDirect(dp.getAddress())) { super.send(dp); - log.debug("Sending datagram packet directly:"); + // log.debug("Sending datagram packet directly:"); return; }
@@ -386,7 +381,7 @@ public class Socks5DatagramSocket extends DatagramSocket { if (eof < 0) { return false; // EOF encountered. } else { - log.warn("This really should not happen"); + //log.warn("This really should not happen"); return true; // This really should not happen }
diff --git a/src/com/runjva/sourceforge/jsocks/protocol/Socks5Message.java b/src/com/runjva/sourceforge/jsocks/protocol/Socks5Message.java index 0f24715..c61c882 100644 --- a/src/com/runjva/sourceforge/jsocks/protocol/Socks5Message.java +++ b/src/com/runjva/sourceforge/jsocks/protocol/Socks5Message.java @@ -7,9 +7,6 @@ import java.io.OutputStream; import java.net.InetAddress; import java.net.UnknownHostException;
-import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * SOCKS5 request/response message. */ @@ -20,7 +17,6 @@ class Socks5Message extends ProxyMessage {
byte[] data;
- private Logger log = LoggerFactory.getLogger(Socks5Message.class);
/** * Server error response. @@ -98,8 +94,6 @@ class Socks5Message extends ProxyMessage { this.host = hostName; this.version = SOCKS_VERSION;
- log.debug("Doing ATYP_DOMAINNAME"); - addrType = SOCKS_ATYP_DOMAINNAME; final byte addr[] = hostName.getBytes();
@@ -215,7 +209,7 @@ class Socks5Message extends ProxyMessage { host = bytes2IPV6(addr, 0); break; case SOCKS_ATYP_DOMAINNAME: - log.debug("Reading ATYP_DOMAINNAME"); +// log.debug("Reading ATYP_DOMAINNAME"); addr = new byte[di.readUnsignedByte()];// Next byte shows the length di.readFully(addr); host = new String(addr); diff --git a/src/com/runjva/sourceforge/jsocks/protocol/SocksSocket.java b/src/com/runjva/sourceforge/jsocks/protocol/SocksSocket.java index fd626ec..5e7f427 100644 --- a/src/com/runjva/sourceforge/jsocks/protocol/SocksSocket.java +++ b/src/com/runjva/sourceforge/jsocks/protocol/SocksSocket.java @@ -8,9 +8,6 @@ import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException;
-import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * SocksSocket tryies to look very similar to normal Socket, while allowing * connections through the SOCKS4 or 5 proxy. To use this class you will have to @@ -57,7 +54,7 @@ public class SocksSocket extends Socket { protected int localPort, remotePort;
private Socket directSock = null; - private Logger log = LoggerFactory.getLogger(SocksSocket.class); + //private Logger log = LoggerFactory.getLogger(SocksSocket.class);
/** * Tryies to connect to given host and port using default proxy. If no @@ -373,7 +370,7 @@ public class SocksSocket extends Socket {
private void doDirect() throws SocksException { try { - log.debug("IP: {}_{}", remoteIP, remotePort); + // log.debug("IP: {}_{}", remoteIP, remotePort); directSock = new Socket(remoteIP, remotePort); proxy.out = directSock.getOutputStream(); proxy.in = directSock.getInputStream(); diff --git a/src/com/runjva/sourceforge/jsocks/protocol/UDPRelayServer.java b/src/com/runjva/sourceforge/jsocks/protocol/UDPRelayServer.java index 14599c7..d4a158e 100644 --- a/src/com/runjva/sourceforge/jsocks/protocol/UDPRelayServer.java +++ b/src/com/runjva/sourceforge/jsocks/protocol/UDPRelayServer.java @@ -8,9 +8,6 @@ import java.net.InetAddress; import java.net.Socket; import java.net.UnknownHostException;
-import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.runjva.sourceforge.jsocks.server.ServerAuthenticator;
/** @@ -33,7 +30,7 @@ class UDPRelayServer implements Runnable {
long lastReadTime;
- static Logger log = LoggerFactory.getLogger(UDPRelayServer.class); +// static Logger log = LoggerFactory.getLogger(UDPRelayServer.class); static SocksProxyBase proxy = null; static int datagramSize = 0xFFFF;// 64K, a bit more than max udp size static int iddleTimeout = 180000;// 3 minutes @@ -124,9 +121,9 @@ class UDPRelayServer implements Runnable { remote_sock.setSoTimeout(iddleTimeout); client_sock.setSoTimeout(iddleTimeout);
- log.info("Starting UDP relay server on {}:{}", relayIP, relayPort); - log.info("Remote socket {}:{}", remote_sock.getLocalAddress(), - remote_sock.getLocalPort()); + //log.info("Starting UDP relay server on {}:{}", relayIP, relayPort); + // log.info("Remote socket {}:{}", remote_sock.getLocalAddress(), + // remote_sock.getLocalPort());
pipe_thread1 = new Thread(this, "pipe1"); pipe_thread2 = new Thread(this, "pipe2"); @@ -160,8 +157,8 @@ class UDPRelayServer implements Runnable { } catch (final IOException ioe) { } finally { abort(); - log.info("UDP Pipe thread " + Thread.currentThread().getName() - + " stopped."); + // log.info("UDP Pipe thread " + Thread.currentThread().getName() + // + " stopped."); }
} @@ -173,7 +170,7 @@ class UDPRelayServer implements Runnable { return; }
- log.info("Aborting UDP Relay Server"); + // log.info("Aborting UDP Relay Server");
remote_sock.close(); client_sock.close(); @@ -210,7 +207,7 @@ class UDPRelayServer implements Runnable { }
} catch (final UnknownHostException uhe) { - log.info("Dropping datagram for unknown host"); + // log.info("Dropping datagram for unknown host"); } catch (final InterruptedIOException iioe) { // log("Interrupted: "+iioe); // If we were interrupted by other thread. diff --git a/src/com/runjva/sourceforge/jsocks/server/Ident.java b/src/com/runjva/sourceforge/jsocks/server/Ident.java index 7193f79..6e0940c 100644 --- a/src/com/runjva/sourceforge/jsocks/server/Ident.java +++ b/src/com/runjva/sourceforge/jsocks/server/Ident.java @@ -8,9 +8,6 @@ import java.net.ConnectException; import java.net.Socket; import java.util.StringTokenizer;
-import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - /** * Class Ident provides means to obtain user name of the owner of the socket on * remote machine, providing remote machine runs identd daemon. @@ -24,7 +21,7 @@ import org.slf4j.LoggerFactory; */ public class Ident {
- Logger log = LoggerFactory.getLogger(Ident.class); +// Logger log = LoggerFactory.getLogger(Ident.class);
/** Error Message can be null. */ public String errorMessage; @@ -118,7 +115,7 @@ public class Ident { sock.close(); } } catch (final IOException ioe) { - log.warn("Could not close socket", ioe); + // log.warn("Could not close socket", ioe); } } } diff --git a/src/org/torproject/android/OrbotMainActivity.java b/src/org/torproject/android/OrbotMainActivity.java index 99b613e..1dfe133 100644 --- a/src/org/torproject/android/OrbotMainActivity.java +++ b/src/org/torproject/android/OrbotMainActivity.java @@ -8,7 +8,6 @@ import info.guardianproject.browser.Browser; import java.net.URLDecoder; import java.util.Locale;
-import org.sandroproxy.ony.R; import org.torproject.android.service.TorService; import org.torproject.android.service.TorServiceConstants; import org.torproject.android.service.TorServiceUtils; @@ -74,6 +73,11 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC private Button mBtnBrowser = null; private Button mBtnVPN = null;
+ private DrawerLayout mDrawer; + private ActionBarDrawerToggle mDrawerToggle; + private Toolbar mToolbar; + + /* Some tracking bits */ private int torStatus = TorServiceConstants.STATUS_OFF; //latest status reported from the tor service
@@ -92,7 +96,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
setLocale();
-<<<<<<< HEAD:src/org/torproject/android/OrbotMainActivity.java doLayout();
// appConflictChecker (); @@ -118,44 +121,7 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC } - // Our handler for received Intents. This will be called whenever an Intent - // with an action named "custom-event-name" is broadcasted. - private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() { - - - - @Override - public void onReceive(Context context, Intent intent) { - // Get extra data included in the Intent - - if (intent.hasExtra("log")) - { - String log = intent.getStringExtra("log"); - updateStatus(log); - } - else if (intent.hasExtra("up")) - { - long upload = intent.getLongExtra("up",0); - long download = intent.getLongExtra("down",0); - long written = intent.getLongExtra("written",0); - long read = intent.getLongExtra("read",0); - - Message msg = mHandler.obtainMessage(TorServiceConstants.MESSAGE_TRAFFIC_COUNT); - msg.getData().putLong("download", download); - msg.getData().putLong("upload", upload); - msg.getData().putLong("readTotal", read); - msg.getData().putLong("writeTotal", written); - mHandler.sendMessage(msg); - - } - else if (intent.hasExtra("status")) - { - torStatus = intent.getIntExtra("status", TorServiceConstants.STATUS_OFF); - updateStatus(""); - } - - } - }; +
private void startService (String action) { @@ -174,72 +140,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC } - private DrawerLayout mDrawer; - private ActionBarDrawerToggle mDrawerToggle; - private Toolbar mToolbar; - - private void doLayout () - { - setContentView(R.layout.layout_main); - - mToolbar = (Toolbar) findViewById(R.id.toolbar); - mToolbar.inflateMenu(R.menu.orbot_main); - mToolbar.setTitle(R.string.app_name); - - mDrawer = (DrawerLayout) findViewById(R.id.drawer_layout); - mDrawerToggle = new ActionBarDrawerToggle( - this, mDrawer, mToolbar, - android.R.string.ok, android.R.string.cancel - ); - - mDrawer.setDrawerListener(mDrawerToggle); - mDrawerToggle.setDrawerIndicatorEnabled(true); - mDrawerToggle.syncState(); - mDrawerToggle.setToolbarNavigationClickListener(new OnClickListener () - { - - @Override - public void onClick(View v) { - - - - } - - - }); - - - lblStatus = (TextView)findViewById(R.id.lblStatus); - imgStatus = (ImageProgressView)findViewById(R.id.imgStatus); - imgStatus.setOnLongClickListener(this); - - downloadText = (TextView)findViewById(R.id.trafficDown); - uploadText = (TextView)findViewById(R.id.trafficUp); -======= - doLayout(); - - appConflictChecker (); - - - // Register to receive messages. - // We are registering an observer (mMessageReceiver) to receive Intents - // with actions named "custom-event-name". - LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, - new IntentFilter("status")); - - LocalBroadcastManager.getInstance(this).registerReceiver(mMessageReceiver, - new IntentFilter("log")); - - mHandler.postDelayed(new Runnable () - { - - public void run () - { - startService(TorServiceConstants.CMD_INIT); - } - },INIT_DELAY); - - }
// Our handler for received Intents. This will be called whenever an Intent // with an action named "custom-event-name" is broadcasted. @@ -280,30 +180,12 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC } };
- ProgressDialog mProgressDialog; - - private void startService (String action) - { - - Intent torService = new Intent(this, TorService.class); - torService.setAction(action); - startService(torService); - - } - - private void stopService () - { - - Intent torService = new Intent(this, TorService.class); - stopService(torService); - - } +
private void doLayout () { setContentView(R.layout.layout_main);
- mViewMain = findViewById(R.id.viewMain); lblStatus = (TextView)findViewById(R.id.lblStatus); lblStatus.setOnLongClickListener(this); imgStatus = (ImageProgressView)findViewById(R.id.imgStatus); @@ -314,42 +196,7 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
downloadText = (TextView)findViewById(R.id.trafficDown); uploadText = (TextView)findViewById(R.id.trafficUp); - mTxtOrbotLog = (TextView)findViewById(R.id.orbotLog);
- mDrawer = ((SlidingDrawer)findViewById(R.id.SlidingDrawer)); - Button slideButton = (Button)findViewById(R.id.slideButton); - if (slideButton != null) - { - slideButton.setOnTouchListener(new OnTouchListener (){ - - @Override - public boolean onTouch(View v, MotionEvent event) { - - if (event.equals(MotionEvent.ACTION_DOWN)) - { - mDrawerOpen = !mDrawerOpen; - mTxtOrbotLog.setEnabled(mDrawerOpen); - } - return false; - } - - }); - } - - ScrollingMovementMethod smm = new ScrollingMovementMethod(); - - mTxtOrbotLog.setMovementMethod(smm); - mTxtOrbotLog.setOnLongClickListener(new View.OnLongClickListener() { - - - @Override - public boolean onLongClick(View v) { - ClipboardManager cm = (ClipboardManager)getSystemService(Context.CLIPBOARD_SERVICE); - cm.setText(mTxtOrbotLog.getText()); - Toast.makeText(Orbot.this, "LOG COPIED TO CLIPBOARD", Toast.LENGTH_SHORT).show(); - return true; - } - });
downloadText.setText(formatCount(0) + " / " + formatTotal(0)); uploadText.setText(formatCount(0) + " / " + formatTotal(0)); @@ -396,23 +243,7 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
} - private void appendLogTextAndScroll(String text) - { - if(mTxtOrbotLog != null && text != null && text.length() > 0){ - - if (mTxtOrbotLog.getText().length() > MAX_LOG_LENGTH) - mTxtOrbotLog.setText(""); - - mTxtOrbotLog.append(text + "\n"); - final Layout layout = mTxtOrbotLog.getLayout(); - if(layout != null){ - int scrollDelta = layout.getLineBottom(mTxtOrbotLog.getLineCount() - 1) - - mTxtOrbotLog.getScrollY() - mTxtOrbotLog.getHeight(); - if(scrollDelta > 0) - mTxtOrbotLog.scrollBy(0, scrollDelta); - } - } - } +
/* * Create the UI Options Menu (non-Javadoc) @@ -839,308 +670,9 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC } - private void startIntent (String pkg, String action, Uri data) - { - Intent i; - PackageManager manager = getPackageManager(); - try { - i = manager.getLaunchIntentForPackage(pkg); - if (i == null) - throw new PackageManager.NameNotFoundException(); - i.setAction(action); - i.setData(data); - startActivity(i); - } catch (PackageManager.NameNotFoundException e) { - - } - } - private boolean appInstalledOrNot(String uri) -======= - * @see android.app.Activity#onPause() - */ - protected void onPause() { - try - { - super.onPause(); - - if (aDialog != null) - aDialog.dismiss(); - } - catch (IllegalStateException ise) - { - //can happen on exit/shutdown - } - } - - private void doTorCheck () - { - - DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { - - public void onClick(DialogInterface dialog, int which) { - switch (which){ - case DialogInterface.BUTTON_POSITIVE: - - openBrowser(URL_TOR_CHECK); - - - - break; - - case DialogInterface.BUTTON_NEGATIVE: - - //do nothing - break; - } - } - }; - - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(R.string.tor_check).setPositiveButton(R.string.btn_okay, dialogClickListener) - .setNegativeButton(R.string.btn_cancel, dialogClickListener).show(); - - } - - private void enableHiddenServicePort (int hsPort) - { - - Editor pEdit = mPrefs.edit(); - - String hsPortString = mPrefs.getString("pref_hs_ports", ""); - - if (hsPortString.length() > 0 && hsPortString.indexOf(hsPort+"")==-1) - hsPortString += ',' + hsPort; - else - hsPortString = hsPort + ""; - - pEdit.putString("pref_hs_ports", hsPortString); - pEdit.putBoolean("pref_hs_enable", true); - - pEdit.commit(); - - String onionHostname = mPrefs.getString("pref_hs_hostname",""); - - while (onionHostname.length() == 0) - { - //we need to stop and start Tor - try { - stopTor(); - - Thread.sleep(3000); //wait three seconds - - startTor(); - } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - onionHostname = mPrefs.getString("pref_hs_hostname",""); - } - - Intent nResult = new Intent(); - nResult.putExtra("hs_host", onionHostname); - setResult(RESULT_OK, nResult);
- }
- - private synchronized void handleIntents () - { - if (getIntent() == null) - return; - - // Get intent, action and MIME type - Intent intent = getIntent(); - String action = intent.getAction(); - String type = intent.getType(); - - if (action == null) - return; - - if (action.equals("org.torproject.android.REQUEST_HS_PORT")) - { - - DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() { - - public void onClick(DialogInterface dialog, int which) { - switch (which){ - case DialogInterface.BUTTON_POSITIVE: - - int hsPort = getIntent().getIntExtra("hs_port", -1); - - enableHiddenServicePort (hsPort); - - finish(); - - - break; - - case DialogInterface.BUTTON_NEGATIVE: - //No button clicked - finish(); - break; - } - } - }; - - int hsPort = getIntent().getIntExtra("hs_port", -1); - - String requestMsg = getString(R.string.hidden_service_request, hsPort); - AlertDialog.Builder builder = new AlertDialog.Builder(this); - builder.setMessage(requestMsg).setPositiveButton("Allow", dialogClickListener) - .setNegativeButton("Deny", dialogClickListener).show(); - - - } - else if (action.equals("org.torproject.android.START_TOR")) - { - autoStartFromIntent = true; - - try { - startTor(); - - Intent nResult = new Intent(); - - //nResult.putExtra("socks", ); //TODO respond with socks, transport, dns, etc - - setResult(RESULT_OK,nResult); - - } catch (RemoteException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - - } - else if (action.equals(Intent.ACTION_VIEW)) - { - String urlString = intent.getDataString(); - - if (urlString != null) - { - - if (urlString.toLowerCase().startsWith("bridge://")) - - { - String newBridgeValue = urlString.substring(9); //remove the bridge protocol piece - newBridgeValue = URLDecoder.decode(newBridgeValue); //decode the value here - - showAlert("Bridges Updated","Restart Orbot to use this bridge: " + newBridgeValue,false); - - String bridges = mPrefs.getString(TorConstants.PREF_BRIDGES_LIST, null); - - Editor pEdit = mPrefs.edit(); - - if (bridges != null && bridges.trim().length() > 0) - { - if (bridges.indexOf('\n')!=-1) - bridges += '\n' + newBridgeValue; - else - bridges += ',' + newBridgeValue; - } - else - bridges = newBridgeValue; - - pEdit.putString(TorConstants.PREF_BRIDGES_LIST,bridges); //set the string to a preference - pEdit.putBoolean(TorConstants.PREF_BRIDGES_ENABLED,true); - - pEdit.commit(); - - setResult(RESULT_OK); - } - } - } - else - { - - showWizard = mPrefs.getBoolean("show_wizard",showWizard); - - if (showWizard) - { - Editor pEdit = mPrefs.edit(); - pEdit.putBoolean("show_wizard",false); - pEdit.commit(); - showWizard = false; - - startActivity(new Intent(this, ChooseLocaleWizardActivity.class)); - - } - - } - - setIntent(null); - - updateStatus (""); - - } - - private boolean showWizard = true; - - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - - doLayout(); - updateStatus(""); - } - - - /* - * Launch the system activity for Uri viewing with the provided url - */ - private void openBrowser(final String browserLaunchUrl) - { - boolean isOrwebInstalled = appInstalledOrNot("info.guardianproject.browser"); - boolean isTransProxy = mPrefs.getBoolean("pref_transparent", false); - - if (isOrwebInstalled) - { - startIntent("info.guardianproject.browser",Intent.ACTION_VIEW,Uri.parse(browserLaunchUrl)); - } - else if (isTransProxy) - { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); - intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - } - else - { - AlertDialog aDialog = new AlertDialog.Builder(Orbot.this) - .setIcon(R.drawable.onion32) - .setTitle(R.string.install_apps_) - .setMessage(R.string.it_doesn_t_seem_like_you_have_orweb_installed_want_help_with_that_or_should_we_just_open_the_browser_) - .setPositiveButton(android.R.string.ok, new OnClickListener () - { - - @Override - public void onClick(DialogInterface dialog, int which) { - - //prompt to install Orweb - Intent intent = new Intent(Orbot.this,TipsAndTricks.class); - startActivity(intent); - - } - - }) - .setNegativeButton(android.R.string.no, new OnClickListener () - { - - @Override - public void onClick(DialogInterface dialog, int which) { - Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(browserLaunchUrl)); - intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP|Intent.FLAG_ACTIVITY_NEW_TASK); - startActivity(intent); - - } - - }) - .show(); - - } - - } - private void startIntent (String pkg, String action, Uri data) { Intent i; @@ -1448,7 +980,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC
}
-<<<<<<< HEAD:src/org/torproject/android/OrbotMainActivity.java return true;
} @@ -1456,35 +987,6 @@ public class OrbotMainActivity extends Activity implements TorConstants, OnLongC { Log.d(TAG,"error onclick",e); } - -======= - if (!mDrawerOpen) - { - try - { - - if (torStatus == TorServiceConstants.STATUS_OFF) - { - - startTor(); - } - else - { - - stopTor(); - stopService (); - - } - - return true; - - } - catch (Exception e) - { - Log.d(TAG,"error onclick",e); - } - - }
return false;
diff --git a/src/org/torproject/android/service/TorResourceInstaller.java b/src/org/torproject/android/service/TorResourceInstaller.java index d10ccdb..07cb4fd 100644 --- a/src/org/torproject/android/service/TorResourceInstaller.java +++ b/src/org/torproject/android/service/TorResourceInstaller.java @@ -17,13 +17,12 @@ import java.util.concurrent.TimeoutException; import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream;
-import org.sandroproxy.ony.R; import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.command.SimpleCommand; +import org.torproject.android.R; import org.torproject.android.TorConstants;
import android.content.Context; -import android.os.Build; import android.util.Log;
public class TorResourceInstaller implements TorServiceConstants { diff --git a/src/org/torproject/android/service/TorService.java b/src/org/torproject/android/service/TorService.java index a13b3b8..423f62c 100644 --- a/src/org/torproject/android/service/TorService.java +++ b/src/org/torproject/android/service/TorService.java @@ -45,7 +45,6 @@ import net.freehaven.tor.control.TorControlConnection;
import org.json.JSONArray; import org.json.JSONObject; -import org.sandroproxy.ony.R; import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.torproject.android.OrbotMainActivity; @@ -58,7 +57,6 @@ import org.torproject.android.vpn.OrbotVpnService; import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Application; -import android.app.IntentService; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; @@ -235,33 +233,13 @@ public class TorService extends Service implements TorServiceConstants, TorConst mNotificationShowing = false;
} -<<<<<<< HEAD - - private void clearNotifications () - { - if (mNotificationManager != null) - mNotificationManager.cancelAll(); - - - hmBuiltNodes.clear(); - mNotificationShowing = false; - - } - - @SuppressLint("NewApi") - private void showToolbarNotification (String notifyMsg, int notifyType, int icon) - { - - //Reusable code. - Intent intent = new Intent(TorService.this, OrbotMainActivity.class); - PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0); - + @SuppressLint("NewApi") private void showToolbarNotification (String notifyMsg, int notifyType, int icon) {
//Reusable code. - Intent intent = new Intent(TorService.this, Orbot.class); + Intent intent = new Intent(TorService.this, OrbotMainActivity.class); PendingIntent pendIntent = PendingIntent.getActivity(TorService.this, 0, intent, 0);
if (mNotifyBuilder == null) diff --git a/src/org/torproject/android/settings/AppManager.java b/src/org/torproject/android/settings/AppManager.java index 6214307..5818519 100644 --- a/src/org/torproject/android/settings/AppManager.java +++ b/src/org/torproject/android/settings/AppManager.java @@ -6,18 +6,14 @@ package org.torproject.android.settings; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; -import java.util.Comparator; import java.util.Iterator; import java.util.List; import java.util.StringTokenizer;
-import org.sandroproxy.ony.R; +import org.torproject.android.R; import org.torproject.android.TorConstants; -import org.torproject.android.service.TorService; import org.torproject.android.service.TorServiceUtils;
- -//import android.R; import android.app.Activity; import android.content.Context; import android.content.SharedPreferences; @@ -25,15 +21,10 @@ import android.content.SharedPreferences.Editor; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.os.Build; import android.os.Bundle; import android.util.Log; import android.view.LayoutInflater; -import android.view.MenuItem.OnMenuItemClickListener; import android.view.View; -import android.view.Menu; -import android.view.MenuItem; -import android.view.MenuInflater; import android.view.View.OnClickListener; import android.view.ViewGroup; import android.widget.ArrayAdapter; @@ -45,6 +36,7 @@ import android.widget.ImageView; import android.widget.ListAdapter; import android.widget.ListView; import android.widget.TextView; +//import android.R;
public class AppManager extends Activity implements OnCheckedChangeListener, OnClickListener, TorConstants {
diff --git a/src/org/torproject/android/settings/SettingsPreferences.java b/src/org/torproject/android/settings/SettingsPreferences.java index 0fd9a89..0e7f837 100644 --- a/src/org/torproject/android/settings/SettingsPreferences.java +++ b/src/org/torproject/android/settings/SettingsPreferences.java @@ -5,8 +5,8 @@ package org.torproject.android.settings;
import java.util.Locale;
-import org.sandroproxy.ony.R; import org.sufficientlysecure.rootcommands.RootCommands; +import org.torproject.android.R; import org.torproject.android.service.TorServiceUtils;
import android.content.Context; @@ -19,7 +19,6 @@ import android.preference.Preference; import android.preference.Preference.OnPreferenceClickListener; import android.preference.PreferenceActivity; import android.preference.PreferenceCategory; -import android.preference.PreferenceManager; import android.widget.Toast;
diff --git a/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java b/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java index 6fdd503..ff4a0aa 100644 --- a/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java +++ b/src/org/torproject/android/ui/ChooseLocaleWizardActivity.java @@ -2,7 +2,7 @@ package org.torproject.android.ui;
import java.util.Locale;
-import org.sandroproxy.ony.R; +import org.torproject.android.R; import org.torproject.android.TorConstants; import org.torproject.android.service.TorServiceUtils;
@@ -12,7 +12,6 @@ import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.content.res.Configuration; import android.os.Bundle; -import android.util.Log; import android.view.KeyEvent; import android.view.View; import android.widget.AdapterView; diff --git a/src/org/torproject/android/ui/LotsaText.java b/src/org/torproject/android/ui/LotsaText.java index 1601fe6..5fdaa57 100644 --- a/src/org/torproject/android/ui/LotsaText.java +++ b/src/org/torproject/android/ui/LotsaText.java @@ -1,6 +1,6 @@ package org.torproject.android.ui;
-import org.sandroproxy.ony.R; +import org.torproject.android.R; import org.torproject.android.TorConstants; import org.torproject.android.service.TorServiceUtils;
diff --git a/src/org/torproject/android/ui/OrbotDiagnosticsActivity.java b/src/org/torproject/android/ui/OrbotDiagnosticsActivity.java index 685093a..5a01a94 100644 --- a/src/org/torproject/android/ui/OrbotDiagnosticsActivity.java +++ b/src/org/torproject/android/ui/OrbotDiagnosticsActivity.java @@ -7,14 +7,9 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.util.ArrayList;
-import org.sandroproxy.ony.R; import org.sufficientlysecure.rootcommands.Shell; import org.sufficientlysecure.rootcommands.command.SimpleCommand; import org.torproject.android.R; -import org.torproject.android.R.id; -import org.torproject.android.R.layout; -import org.torproject.android.R.menu; -import org.torproject.android.R.raw; import org.torproject.android.service.TorResourceInstaller; import org.torproject.android.service.TorServiceConstants;
diff --git a/src/org/torproject/android/vpn/OrbotVpnService.java b/src/org/torproject/android/vpn/OrbotVpnService.java index 483529a..22a8af1 100644 --- a/src/org/torproject/android/vpn/OrbotVpnService.java +++ b/src/org/torproject/android/vpn/OrbotVpnService.java @@ -18,35 +18,26 @@ package org.torproject.android.vpn;
import java.io.IOException; import java.net.InetAddress; -import java.nio.ByteBuffer; import java.util.Locale; -import java.util.Set;
-import org.sandroproxy.ony.R; -import org.torproject.android.Orbot; -import org.torproject.android.service.TorService; import org.torproject.android.service.TorServiceConstants;
-import com.runjva.sourceforge.jsocks.protocol.ProxyServer; -import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone; - -import android.annotation.SuppressLint; import android.annotation.TargetApi; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; -import android.content.Context; import android.content.Intent; import android.net.VpnService; import android.os.Build; import android.os.Handler; import android.os.Message; import android.os.ParcelFileDescriptor; -import android.support.v4.app.NotificationCompat; import android.util.Log; -import android.widget.RemoteViews; import android.widget.Toast;
+import com.runjva.sourceforge.jsocks.protocol.ProxyServer; +import com.runjva.sourceforge.jsocks.server.ServerAuthenticatorNone; + @TargetApi(Build.VERSION_CODES.ICE_CREAM_SANDWICH) public class OrbotVpnService extends VpnService implements Handler.Callback { private static final String TAG = "DrobotVpnService"; @@ -61,6 +52,7 @@ public class OrbotVpnService extends VpnService implements Handler.Callback {
private int mSocksProxyPort = 9999; private ProxyServer mProxyServer; + private Thread mThreadProxy;
private final static int VPN_MTU = 1500;
@@ -229,7 +221,6 @@ public class OrbotVpnService extends VpnService implements Handler.Callback { } } }.start(); - clearNotifications(); super.onRevoke(); }