android-vpn-service

What is the correct way to convert my IP Packet data into a String?

二次信任 提交于 2020-01-06 05:47:14
问题 When I receive an IP Packet with my Android VpnService I read the headers first (as here), then I try to print the received data as follows: int lengthRemaining = packet.remaining(); if (lengthRemaining > 0) { byte[] data = new byte[lengthRemaining]; packet.get(data, packet.arrayOffset(), lengthRemaining); Log.d(TAG, "Packet-Data: " + new String(data, Charset.forName("UTF-8"))); } This results in out put like the following: Packet-Data: ����5��(��������������������www�google�com������ Or

Programmatically setting up a vpn on Android

冷暖自知 提交于 2019-12-18 17:25:55
问题 I have found the following code to establish a new vpn programmatically but I do not know how to use it to create my app VpnService service = context.getSystemService(VPN_SERVICE); VpnProfile profile = VpnProfile.create(L2TP_PROFILE); profile.setName(myServerName); profile.setServerName(myServerAddress); profile.setRouteList("192.168.1.0/255.255.255.0,192.168.10.0/255.255.255.0"); service.connect(profile, "myUserName", "myPassword"); service.setNotificationIntent(myIntent); can anyone please

Android VpnService protect socket that's stored in native code?

隐身守侯 提交于 2019-12-09 12:14:40
问题 I'm writing a VPN application and the socket used for the VPN Connection is handled in my native C code, not in java. How do I use VpnService.protect() on that socket? I noticed that it has a VpnService.protect(int) overload, could I return the int that socket returns from the native code to Java and protect it that way? Example // Native Code int socket; JNIEXPORT jint JNICALL Java_com_my_package_Class_initializeSocket ( JNIEnv *env, jobject jobj ) { socket = socket(AF_INET, SOCK_DGRAM, 0);

Android VpnService protect socket that's stored in native code?

馋奶兔 提交于 2019-12-03 14:51:37
I'm writing a VPN application and the socket used for the VPN Connection is handled in my native C code, not in java. How do I use VpnService.protect() on that socket? I noticed that it has a VpnService.protect(int) overload, could I return the int that socket returns from the native code to Java and protect it that way? Example // Native Code int socket; JNIEXPORT jint JNICALL Java_com_my_package_Class_initializeSocket ( JNIEnv *env, jobject jobj ) { socket = socket(AF_INET, SOCK_DGRAM, 0); // . . . Handler other socket preparations return (jint)socket; } // Java Code public native int