private String parseHttpsHost(byte[] buffer, int offset, int size) {
        int limit = offset + size;
        // Client Hello
        if (size <= 43 || buffer[offset] != 0x16) {
            mLog.w("Failed to get host from SNI: Bad ssl packet.");
            return null;
        }
        // Skip 43 byte header
        offset += 43;

        // Read sessionID
        if (offset + 1 > limit) {
            mLog.w("Failed to get host from SNI: No session id.");
            return null;
        }
        int sessionIDLength = buffer[offset++] & 0xFF;
        offset += sessionIDLength;

        // Read cipher suites
        if (offset + 2 > limit) {
            mLog.w("Failed to get host from SNI: No cipher suites.");
            return null;
        }

        int cipherSuitesLength = readShort(buffer, offset) & 0xFFFF;
        offset += 2;
        offset += cipherSuitesLength;

        // Read Compression method.
        if (offset + 1 > limit) {
            mLog.w("Failed to get host from SNI: No compression method.");
            return null;
        }
        int compressionMethodLength = buffer[offset++] & 0xFF;
        offset += compressionMethodLength;

        // Read Extensions
        if (offset + 2 > limit) {
            mLog.w("Failed to get host from SNI: no extensions.");
            return null;
        }
        int extensionsLength = readShort(buffer, offset) & 0xFFFF;
        offset += 2;

        if (offset + extensionsLength > limit) {
            mLog.w("Failed to get host from SNI: no sni.");
            return null;
        }

        while (offset + 4 <= limit) {
            int type0 = buffer[offset++] & 0xFF;
            int type1 = buffer[offset++] & 0xFF;
            int length = readShort(buffer, offset) & 0xFFFF;
            offset += 2;
            // Got the SNI info
            if (type0 == 0x00 && type1 == 0x00 && length > 5) {
                offset += 5;
                length -= 5;
                if (offset + length > limit) {
                    return null;
                }
                return new String(buffer, offset, length);
            } else {
                offset += length;
            }

        }
        mLog.w("Failed to get host from SNI: no host.");
        return null;
    }
This policy doesn't allow data flow to configured virtual gateway.
netbare-core/src/main/java/com/github/megatronking/netbare/NetBareVirtualGateway.java