-
Notifications
You must be signed in to change notification settings - Fork 6
feat: implement network type detection using JNI #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just missing making the library during the build step.
composeApp/src/desktopMain/kotlin/org/ooni/engine/MacOsNetworkTypeFinder.kt
Outdated
Show resolved
Hide resolved
composeApp/src/desktopMain/kotlin/org/ooni/probe/BuildDependencies.kt
Outdated
Show resolved
Hide resolved
…nd update platform detection in Makefile
System.loadLibrary("networktypefinder") | ||
libraryLoaded = true | ||
} catch (e: UnsatisfiedLinkError) { | ||
Logger.d("Failed to load native library: ${e.message}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a warning
log and not debug
log.
"unknown" | ||
} | ||
} catch (e: Throwable) { | ||
Logger.d("Error in native method call: ${e.message}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be a warning
log and not debug
log.
extern "C" { | ||
#endif | ||
|
||
JNIEXPORT jstring JNICALL Java_org_ooni_engine_MacOsNetworkTypeFinder_getNetworkType(JNIEnv *env, jobject obj); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not just MacOs
right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes
#endif | ||
|
||
#if defined(__APPLE__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why close the #if defined(__APPLE__)
to then open it again straight after?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me fix that.
conveyor.conf
Outdated
} | ||
|
||
app.inputs += { | ||
from = "composeApp/src/desktopMain/build/libnetworktypefinder.dylib" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Only the macOs .dylib?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now.
} else if (nw_path_uses_interface_type(currentPath, nw_interface_type_wired)) { | ||
result = @"wired_ethernet"; | ||
} else { | ||
result = @""; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe this should be unknown
too?
} | ||
|
||
// Helper to check if interface is up and has an IP address | ||
static int iface_is_up_and_has_ip(const char *iface) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not return bool
?
int n = sscanf(line, "%63s %lx %lx %X %u %u %u %x %u %u %u", iface, &dest, &gw, &flags, &refcnt, &use, &metric, &mask, &mtu, &win, &irtt); | ||
if (n >= 11 && dest == 0) { // default route | ||
if (is_vpn_iface(iface) && iface_is_up_and_has_ip(iface)) { | ||
strcpy(vpn_iface, iface); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why copy it, if we don't need it? Maybe just have a is_vpn bool flag?
Or match the code below and fclose
and return straight away?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll commit the libraries to the repository once the workflow finishes right?
Closes #660
Check proper embedding of lib with conveyor