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

后端 未结 1 481
粉色の甜心
粉色の甜心 2021-02-08 23:34

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 soc

相关标签:
1条回答
  • 2021-02-09 00:19

    I simply wanted verification that my processes was valid, after completing more testing I've verified that it works.

    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 initializeSocket();
    
    . . . 
    
    int socket = initializeSocket();
    this.protect(socket);
    
    0 讨论(0)
提交回复
热议问题