diff --git a/src/hu/blint/ssldroid/SSLDroid.java b/src/hu/blint/ssldroid/SSLDroid.java index 727c425..7c268a1 100644 --- a/src/hu/blint/ssldroid/SSLDroid.java +++ b/src/hu/blint/ssldroid/SSLDroid.java @@ -32,6 +32,8 @@ public class SSLDroid extends Service { int i; for (i=0; i 0) { if (Thread.interrupted()) { // We've been interrupted: no more relaying - Log.d("SSLDroid", "Interrupted thread"); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": Interrupted "+side+" thread"); try { in.close(); out.close(); } catch (IOException e) { - Log.d("SSLDroid", e.toString()); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": "+e.toString()); } return; } @@ -129,23 +136,22 @@ public class TcpProxyServerThread extends Thread { } } } catch (SocketException e) { - Log.d("SSLDroid", e.toString()); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": "+e.toString()); } catch (IOException e) { - Log.d("SSLDroid", e.toString()); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": "+e.toString()); } finally { try { in.close(); out.close(); } catch (IOException e) { - Log.d("SSLDroid", e.toString()); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": "+e.toString()); } } - Log.d("SSLDroid", "Quitting stream proxy..."); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": Quitting "+side+"-side stream proxy..."); } } public void run() { - //TODO: logging session ID while (true) { try { @@ -153,7 +159,7 @@ public class TcpProxyServerThread extends Thread { Thread fromServerToBrowser = null; if (isInterrupted()){ - Log.d("SSLDroid", "Interrupted server thread, closing sockets..."); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": Interrupted server thread, closing sockets..."); ss.close(); if (fromBrowserToServer != null) fromBrowserToServer.notify(); @@ -165,6 +171,7 @@ public class TcpProxyServerThread extends Thread { Socket sc = null; try { sc = ss.accept(); + sessionid++; } catch (SocketException e){ Log.d("SSLDroid", "Accept failure: " + e.toString()); } @@ -172,37 +179,37 @@ public class TcpProxyServerThread extends Thread { Socket st = null; try { - st = (SSLSocket) getSocketFactory(this.keyFile, this.keyPass).createSocket(this.tunnelHost, this.tunnelPort); + st = (SSLSocket) getSocketFactory(this.keyFile, this.keyPass, this.sessionid).createSocket(this.tunnelHost, this.tunnelPort); ((SSLSocket) st).startHandshake(); } catch (IOException e){ } catch (Exception e) { - Log.d("SSLDroid", "SSL failure: " + e.toString()); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": SSL failure: " + e.toString()); sc.close(); return; } if (sc == null){ - Log.d("SSLDroid", "Trying socket operation on a null socket, returning"); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": Trying socket operation on a null socket, returning"); return; } - Log.d("SSLDroid", "Tunnelling port " + Log.d("SSLDroid", tunnelName+"/"+sessionid+": Tunnelling port " + listenPort + " to port " + tunnelPort + " on host " + tunnelHost + " ..."); // relay the stuff through fromBrowserToServer = new Relay( - sc.getInputStream(), st.getOutputStream()); + sc.getInputStream(), st.getOutputStream(), "client", sessionid); fromServerToBrowser = new Relay( - st.getInputStream(), sc.getOutputStream()); + st.getInputStream(), sc.getOutputStream(), "server", sessionid); fromBrowserToServer.start(); fromServerToBrowser.start(); } catch (Exception ee) { - Log.d("SSLDroid", "Ouch: " + ee.getMessage()); + Log.d("SSLDroid", tunnelName+"/"+sessionid+": Ouch: " + ee.getMessage()); } } }