1
0
mirror of https://github.com/moparisthebest/SSLDroid synced 2024-11-23 17:32:15 -05:00

Some more cleanup

Signed-off-by: Balint Kovacs <blint@blint.hu>
This commit is contained in:
Balint Kovacs 2011-04-20 19:08:14 +02:00
parent 89d87a89e8
commit 422d217e3b
3 changed files with 2 additions and 23 deletions

Binary file not shown.

Binary file not shown.

View File

@ -1,11 +1,7 @@
package hu.blint.ssldroid; package hu.blint.ssldroid;
import java.io.FileWriter;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.sql.Timestamp;
import java.util.Date;
import android.util.Log; import android.util.Log;
@ -24,19 +20,6 @@ public class TcpProxy {
public TcpProxy() { public TcpProxy() {
} }
public void createNotification(String title, String text) {
try {
FileWriter outFile = new FileWriter("/mnt/sdcard/ssldroid.txt");
PrintWriter out = new PrintWriter(outFile);
Date date= new Date();
out.println(new Timestamp(date.getTime())+" "+title+" "+text);
out.close();
} catch (IOException e){
return;
}
}
public void serve(int listenPort, String tunnelHost, int tunnelPort, String keyFile, String keyPass) throws IOException { public void serve(int listenPort, String tunnelHost, int tunnelPort, String keyFile, String keyPass) throws IOException {
try { try {
ss = new ServerSocket(listenPort); ss = new ServerSocket(listenPort);
@ -48,26 +31,22 @@ public class TcpProxy {
} }
server = new TcpProxyServerThread(ss, listenPort, tunnelHost, tunnelPort, keyFile, keyPass); server = new TcpProxyServerThread(ss, listenPort, tunnelHost, tunnelPort, keyFile, keyPass);
server.start(); server.start();
/* try {
server.wait();
} catch (InterruptedException e) {
Log.d("SSLDroid", "Server thread interrupted: " + e.toString());
} */
} }
public void stop() { public void stop() {
if (server != null){ if (server != null){
try { try {
//close the server socket and interrupt the server thread
ss.close(); ss.close();
server.interrupt(); server.interrupt();
} catch (Exception e) { } catch (Exception e) {
Log.d("SSLDroid", "Interrupt failure: " + e.toString()); Log.d("SSLDroid", "Interrupt failure: " + e.toString());
createNotification(e.getMessage(), "Ouch: "+e.toString());;
} }
} }
Log.d("SSLDroid", "Stopping service"); Log.d("SSLDroid", "Stopping service");
} }
//if the listening socket is still active, we're alive
public boolean isAlive(){ public boolean isAlive(){
return ss.isBound(); return ss.isBound();
} }