1
0
Fork 0
mirror of https://github.com/M66B/NetGuard.git synced 2025-01-03 05:44:14 +00:00

Added logging

This commit is contained in:
M66B 2019-07-28 08:32:02 +02:00
parent c20f216f36
commit 297e352b03

View file

@ -1451,13 +1451,13 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
jni_socks5("", 0, "", ""); jni_socks5("", 0, "", "");
if (tunnelThread == null) { if (tunnelThread == null) {
Log.i(TAG, "Starting tunnel thread"); Log.i(TAG, "Starting tunnel thread context=" + jni_context);
jni_start(jni_context, prio); jni_start(jni_context, prio);
tunnelThread = new Thread(new Runnable() { tunnelThread = new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
Log.i(TAG, "Running tunnel"); Log.i(TAG, "Running tunnel context=" + jni_context);
jni_run(jni_context, vpn.getFd(), mapForward.containsKey(53), rcode); jni_run(jni_context, vpn.getFd(), mapForward.containsKey(53), rcode);
Log.i(TAG, "Tunnel exited"); Log.i(TAG, "Tunnel exited");
tunnelThread = null; tunnelThread = null;
@ -1480,12 +1480,15 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
jni_stop(jni_context); jni_stop(jni_context);
Thread thread = tunnelThread; Thread thread = tunnelThread;
while (thread != null) while (thread != null && thread.isAlive()) {
try { try {
Log.i(TAG, "Joining tunnel thread context=" + jni_context);
thread.join(); thread.join();
break;
} catch (InterruptedException ignored) { } catch (InterruptedException ignored) {
Log.i(TAG, "Joined tunnel interrupted");
} }
thread = tunnelThread;
}
tunnelThread = null; tunnelThread = null;
if (clear) if (clear)
@ -2352,6 +2355,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
if (jni_context != 0) { if (jni_context != 0) {
Log.w(TAG, "Create with context=" + jni_context);
jni_stop(jni_context); jni_stop(jni_context);
synchronized (jni_lock) { synchronized (jni_lock) {
jni_done(jni_context); jni_done(jni_context);
@ -2361,6 +2365,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
// Native init // Native init
jni_context = jni_init(Build.VERSION.SDK_INT); jni_context = jni_init(Build.VERSION.SDK_INT);
Log.i(TAG, "Created context=" + jni_context);
boolean pcap = prefs.getBoolean("pcap", false); boolean pcap = prefs.getBoolean("pcap", false);
setPcap(pcap, this); setPcap(pcap, this);
@ -2721,6 +2726,7 @@ public class ServiceSinkhole extends VpnService implements SharedPreferences.OnS
Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex)); Log.e(TAG, ex.toString() + "\n" + Log.getStackTraceString(ex));
} }
Log.i(TAG, "Destroy context=" + jni_context);
synchronized (jni_lock) { synchronized (jni_lock) {
jni_done(jni_context); jni_done(jni_context);
jni_context = 0; jni_context = 0;