From c1a7c94be9ae02675a91cf59f02438f0ed3661fc Mon Sep 17 00:00:00 2001 From: Balint Kovacs Date: Fri, 15 Apr 2011 08:42:03 +0200 Subject: [PATCH] Fixed shutdown issue and some error handling adjustments Signed-off-by: Balint Kovacs --- src/hu/blint/ssldroid/TcpProxy.java | 40 +------------------ .../blint/ssldroid/TcpProxyServerThread.java | 8 ++-- 2 files changed, 6 insertions(+), 42 deletions(-) diff --git a/src/hu/blint/ssldroid/TcpProxy.java b/src/hu/blint/ssldroid/TcpProxy.java index 5174e76..cf39df1 100644 --- a/src/hu/blint/ssldroid/TcpProxy.java +++ b/src/hu/blint/ssldroid/TcpProxy.java @@ -24,35 +24,6 @@ public class TcpProxy { public TcpProxy() { } - /*public TcpProxy(int listenPort, String tunnelHost, int tunnelPort, - String keyFile, String keyPass) { - this.listenPort = listenPort; - this.tunnelHost = tunnelHost; - this.tunnelPort = tunnelPort; - this.keyFile = keyFile; - this.keyPass = keyPass; - } - - public int getListenPort() { - return listenPort; - } - - public String getTunnelHost() { - return tunnelHost; - } - - public int getTunnelPort() { - return tunnelPort; - } - - public String getKeyFile() { - return keyFile; - } - - public String getKeyPass() { - return keyPass; - } - */ public void createNotification(String title, String text) { try { FileWriter outFile = new FileWriter("/mnt/sdcard/ssldroid.txt"); @@ -66,20 +37,13 @@ public class TcpProxy { } } - public void serve(int listenPort, String tunnelHost, int tunnelPort, - String keyFile, String keyPass) throws IOException { - //final TcpProxy ttg = new TcpProxy(listenPort, tunnelHost, tunnelPort,keyFile, keyPass); - // create the server thread + public void serve(int listenPort, String tunnelHost, int tunnelPort, String keyFile, String keyPass) throws IOException { try { ss = new ServerSocket(listenPort); Log.d("SSLDroid", "Listening for connections on port " + listenPort + " ..."); - //ttg.doLog("Listening for connections on port " + ttg.getListenPort() + " ..."); } catch (Exception e) { - Log.d("SSLDroid", "Error setting up listening socket: " - + e.toString()); - //createNotification(e.getMessage(), "Error setting up listening socket: "+e.toString()); - //e.printStackTrace(); + Log.d("SSLDroid", "Error setting up listening socket: " + e.toString()); System.exit(1); } server = new TcpProxyServerThread(ss, listenPort, tunnelHost, tunnelPort, keyFile, keyPass); diff --git a/src/hu/blint/ssldroid/TcpProxyServerThread.java b/src/hu/blint/ssldroid/TcpProxyServerThread.java index 43195b5..74d37b4 100644 --- a/src/hu/blint/ssldroid/TcpProxyServerThread.java +++ b/src/hu/blint/ssldroid/TcpProxyServerThread.java @@ -193,10 +193,10 @@ public class TcpProxyServerThread extends Thread { ((SSLSocket) st).startHandshake(); } catch (Exception e) { Log.d("SSLDroid", "SSL failure: " + e.toString()); - //createNotification(e.getMessage(), "SSL failure: "+e.toString()); - Thread.sleep(10000); - continue; - //st = new Socket(ttg.getTunnelHost(), ttg.getTunnelPort()); + //Thread.sleep(10000); + //continue; + sc.close(); + return; } Log.d("SSLDroid", "Tunnelling port "