|
|
@ -22,10 +22,6 @@ |
|
|
|
|
|
|
|
#include <assert.h> |
|
|
|
|
|
|
|
#ifdef __ANDROID_NDK__ |
|
|
|
#include <edge_jni/edge_jni.h> |
|
|
|
#endif |
|
|
|
|
|
|
|
#define PURGE_REGISTRATION_FREQUENCY 30 |
|
|
|
#define REGISTRATION_TIMEOUT 60 |
|
|
|
|
|
|
@ -35,47 +31,6 @@ static const uint8_t ipv6_multicast_addr[6] = { 0x33, 0x33, 0x00, 0x00, 0x00, 0x |
|
|
|
|
|
|
|
/* ************************************** */ |
|
|
|
|
|
|
|
#ifdef __ANDROID_NDK__ |
|
|
|
|
|
|
|
static int protect_socket(int sock) { |
|
|
|
JNIEnv *env = NULL; |
|
|
|
|
|
|
|
if(!g_status) |
|
|
|
return(-1); |
|
|
|
|
|
|
|
if ((*g_status->jvm)->GetEnv(g_status->jvm, &env, JNI_VERSION_1_1) != JNI_OK || !env) { |
|
|
|
traceEvent(TRACE_ERROR, "GetEnv failed"); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
|
|
|
|
jclass vpn_service_cls = (*env)->GetObjectClass(env, g_status->jobj_service); |
|
|
|
|
|
|
|
if(!vpn_service_cls) { |
|
|
|
traceEvent(TRACE_ERROR, "GetObjectClass(VpnService) failed"); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
|
|
|
|
/* Call VpnService protect */ |
|
|
|
jmethodID midProtect = (*env)->GetMethodID(env, vpn_service_cls, "protect", "(I)Z"); |
|
|
|
if(!midProtect) { |
|
|
|
traceEvent(TRACE_ERROR, "Could not resolve VpnService::protect"); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
|
|
|
|
jboolean isProtected = (*env)->CallBooleanMethod(env, g_status->jobj_service, midProtect, sock); |
|
|
|
|
|
|
|
if(!isProtected) { |
|
|
|
traceEvent(TRACE_ERROR, "VpnService::protect failed"); |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
|
|
|
|
return(0); |
|
|
|
} |
|
|
|
|
|
|
|
#endif |
|
|
|
|
|
|
|
/* ************************************** */ |
|
|
|
|
|
|
|
SOCKET open_socket(int local_port, int bind_any) { |
|
|
|
SOCKET sock_fd; |
|
|
|
struct sockaddr_in local_address; |
|
|
@ -104,11 +59,6 @@ SOCKET open_socket(int local_port, int bind_any) { |
|
|
|
return(-1); |
|
|
|
} |
|
|
|
|
|
|
|
#ifdef __ANDROID_NDK__ |
|
|
|
/* Protect the socket so that the supernode traffic won't go inside the n2n VPN */ |
|
|
|
protect_socket(sock_fd); |
|
|
|
#endif |
|
|
|
|
|
|
|
return(sock_fd); |
|
|
|
} |
|
|
|
|
|
|
|