mirror of
https://github.com/foxhole-team/foxhole-guard.git
synced 2026-10-21 10:45:41 +02:00
57 lines
2.6 KiB
Diff
57 lines
2.6 KiB
Diff
Subject: [PATCH] Build the standalone i2pd daemon on Android (DaemonUnix)
|
|
|
|
FoxHole execs i2pd as a child process (packaged as libi2pd.so, like libTor.so),
|
|
not as the JNI library the Android target defaults to. Under -DANDROID the daemon
|
|
collapses to the DaemonAndroid stub (no start/stop/run, no gracefulShutdownInterval),
|
|
so daemon/UnixDaemon.cpp fails to compile. Defining ANDROID_BINARY selects the real
|
|
DaemonUnix while leaving the rest of i2pd's Android behaviour intact.
|
|
|
|
--- a/build/CMakeLists.txt
|
|
+++ b/build/CMakeLists.txt
|
|
@@ -180,6 +180,13 @@ if(UNIX)
|
|
list(APPEND DAEMON_SRC "${DAEMON_SRC_DIR}/UnixDaemon.cpp")
|
|
if(NOT(CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR APPLE))
|
|
# "'sleep_for' is not a member of 'std::this_thread'" in gcc 4.7/4.8
|
|
add_definitions("-D_GLIBCXX_USE_NANOSLEEP=1")
|
|
endif()
|
|
+ # FoxHole runs i2pd as a standalone exec'd process (like libTor.so), not the JNI library the
|
|
+ # Android target defaults to. Under -DANDROID the daemon collapses to the DaemonAndroid stub
|
|
+ # (no start/stop/run), so UnixDaemon.cpp fails to compile. Defining ANDROID_BINARY selects the
|
|
+ # real DaemonUnix while keeping the rest of i2pd's Android behaviour intact.
|
|
+ if(ANDROID)
|
|
+ add_definitions("-DANDROID_BINARY")
|
|
+ endif()
|
|
endif()
|
|
|
|
--- a/daemon/HTTPServer.cpp
|
|
+++ b/daemon/HTTPServer.cpp
|
|
@@ -1306,6 +1306,28 @@ namespace http {
|
|
}
|
|
}
|
|
|
|
+ if (req.uri == "/foxhole-status")
|
|
+ {
|
|
+ auto clientTunnelCount = i2p::tunnel::tunnels.CountOutboundTunnels ();
|
|
+ clientTunnelCount += i2p::tunnel::tunnels.CountInboundTunnels ();
|
|
+ s << "foxhole_status=1\n"
|
|
+ << "network_status=" << static_cast<int>(i2p::context.GetStatus ()) << "\n"
|
|
+ << "known_routers=" << i2p::data::netdb.GetNumRouters () << "\n"
|
|
+ << "client_tunnels=" << clientTunnelCount << "\n"
|
|
+ << "transit_tunnels=" << i2p::tunnel::tunnels.CountTransitTunnels () << "\n"
|
|
+ << "received_bytes=" << i2p::transport::transports.GetTotalReceivedBytes () << "\n"
|
|
+ << "sent_bytes=" << i2p::transport::transports.GetTotalSentBytes () << "\n"
|
|
+ << "transit_bytes=" << i2p::transport::transports.GetTotalTransitTransmittedBytes () << "\n"
|
|
+ << "received_bytes_per_sec=" << i2p::transport::transports.GetInBandwidth15s () << "\n"
|
|
+ << "sent_bytes_per_sec=" << i2p::transport::transports.GetOutBandwidth15s () << "\n"
|
|
+ << "transit_bytes_per_sec=" << i2p::transport::transports.GetTransitBandwidth15s () << "\n"
|
|
+ << "version=" VERSION "\n";
|
|
+ res.code = 200;
|
|
+ content = s.str ();
|
|
+ SendReply (res, content);
|
|
+ return;
|
|
+ }
|
|
+
|
|
// HTML head start
|
|
ShowPageHead (s);
|
|
if (req.uri.find("page=") != std::string::npos) {
|