clarify vpnprotect code and add basic debug log

This commit is contained in:
Nathan Freitas 2015-02-02 16:20:26 -05:00
parent ede4128777
commit 4c49822861
1 changed files with 13 additions and 10 deletions

View File

@ -12,11 +12,11 @@ import java.net.InetSocketAddress;
import java.net.NoRouteToHostException; import java.net.NoRouteToHostException;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import java.net.SocketAddress;
import java.nio.channels.SocketChannel; import java.nio.channels.SocketChannel;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.net.VpnService; import android.net.VpnService;
import android.util.Log;
import com.runjva.sourceforge.jsocks.server.ServerAuthenticator; import com.runjva.sourceforge.jsocks.server.ServerAuthenticator;
@ -352,9 +352,8 @@ public class ProxyServer implements Runnable {
Socket s; Socket s;
if (proxy == null) { if (proxy == null) {
//s = new Socket(msg.ip, msg.port);
s= SocketChannel.open().socket(); s = SocketChannel.open().socket();
if ((null != s) && (null != vpnService)) { if ((null != s) && (null != vpnService)) {
vpnService.protect(s); vpnService.protect(s);
} }
@ -363,10 +362,11 @@ public class ProxyServer implements Runnable {
} else { } else {
s = new SocksSocket(proxy, msg.ip, msg.port); s = new SocksSocket(proxy, msg.ip, msg.port);
if (vpnService != null)
vpnService.protect(s);
} }
if (vpnService != null)
vpnService.protect(s);
debug("Connected to " + s.getInetAddress() + ":" + s.getPort()); debug("Connected to " + s.getInetAddress() + ":" + s.getPort());
@ -667,26 +667,29 @@ public class ProxyServer implements Runnable {
public static void debug (String msg) public static void debug (String msg)
{ {
Log.d("Proxy",msg);
} }
public static void debug (String msg, String host, int port) public static void debug (String msg, String host, int port)
{ {
debug (msg);
} }
public static void debug (String msg, Exception e) public static void debug (String msg, Exception e)
{ {
debug (msg);
} }
public static void debug (String msg, InetAddress addr, int port) public static void debug (String msg, InetAddress addr, int port)
{ {
debug (msg);
} }
public static void debug (String msg, int type, String log) public static void debug (String msg, int type, String log)
{ {
debug (msg);
} }
} }