add new JNI function: LokinetDaemon DumpStatus

dev
Jeff Becker 2 years ago
parent 13af82474c
commit 6992d98c6a
Signed by untrusted user who does not match committer: jeff
GPG Key ID: F357B3B42F6F9B05

@ -26,6 +26,9 @@ public class LokinetDaemon extends VpnService
private static native String DetectFreeRange();
public native String DumpStatus();
public static final String LOG_TAG = "LokinetDaemon";
ByteBuffer impl = null;

@ -2,6 +2,7 @@
#include "lokinet_jni_common.hpp"
#include <llarp.hpp>
#include <llarp/config/config.hpp>
#include <llarp/router/abstractrouter.hpp>
extern "C"
{
@ -99,4 +100,23 @@ extern "C"
}
return env->NewStringUTF(rangestr.c_str());
}
JNIEXPORT jstring JNICALL
Java_network_loki_lokinet_LokinetDaemon_DumpStatus(JNIEnv* env, jobject self)
{
std::string status{};
if (auto ptr = GetImpl<llarp::Context>(env, self))
{
if (ptr->IsUp())
{
std::promise<std::string> result;
ptr->CallSafe([&result, router = ptr->router]() {
const auto status = router->ExtractStatus();
result.set_value(status.dump());
});
status = result.get_future().get();
}
}
return env->NewStringUTF(status.c_str());
}
}

@ -80,6 +80,14 @@ extern "C"
JNIEXPORT jstring JNICALL
Java_network_loki_lokinet_LokinetDaemon_DetectFreeRange(JNIEnv*, jclass);
/*
* Class: network_loki_lokinet_LokinetDaemon
* Method: DumpStatus
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL
Java_network_loki_lokinet_LokinetDaemon_DumpStatus(JNIEnv*, jobject);
#ifdef __cplusplus
}
#endif

Loading…
Cancel
Save