-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: r4sas <[email protected]>
- Loading branch information
Showing
24 changed files
with
686 additions
and
450 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := i2pd | ||
LOCAL_CPP_FEATURES := rtti exceptions | ||
LOCAL_C_INCLUDES += $(IFADDRS_PATH) $(LIB_SRC_PATH) $(LIB_CLIENT_SRC_PATH) $(LANG_SRC_PATH) $(DAEMON_SRC_PATH) | ||
LOCAL_STATIC_LIBRARIES := \ | ||
boost_system \ | ||
boost_date_time \ | ||
boost_filesystem \ | ||
boost_program_options \ | ||
crypto \ | ||
ssl \ | ||
miniupnpc | ||
LOCAL_LDLIBS := -lz | ||
|
||
LOCAL_SRC_FILES := \ | ||
DaemonAndroid.cpp \ | ||
i2pd_android.cpp \ | ||
$(IFADDRS_PATH)/ifaddrs.cpp \ | ||
$(IFADDRS_PATH)/bionic_netlink.cpp \ | ||
$(wildcard $(LIB_SRC_PATH)/*.cpp) \ | ||
$(wildcard $(LIB_CLIENT_SRC_PATH)/*.cpp) \ | ||
$(wildcard $(LANG_SRC_PATH)/*.cpp) \ | ||
$(DAEMON_SRC_PATH)/Daemon.cpp \ | ||
$(DAEMON_SRC_PATH)/UPnP.cpp \ | ||
$(DAEMON_SRC_PATH)/HTTPServer.cpp \ | ||
$(DAEMON_SRC_PATH)/I2PControl.cpp \ | ||
$(DAEMON_SRC_PATH)/I2PControlHandlers.cpp | ||
|
||
include $(BUILD_SHARED_LIBRARY) | ||
|
||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := boost_system | ||
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_system.a | ||
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include | ||
include $(PREBUILT_STATIC_LIBRARY) | ||
|
||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := boost_date_time | ||
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_date_time.a | ||
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include | ||
include $(PREBUILT_STATIC_LIBRARY) | ||
|
||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := boost_filesystem | ||
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_filesystem.a | ||
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include | ||
include $(PREBUILT_STATIC_LIBRARY) | ||
|
||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := boost_program_options | ||
LOCAL_SRC_FILES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/lib/libboost_program_options.a | ||
LOCAL_EXPORT_C_INCLUDES := $(BOOST_PATH)/build/out/$(TARGET_ARCH_ABI)/include | ||
include $(PREBUILT_STATIC_LIBRARY) | ||
|
||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := crypto | ||
LOCAL_SRC_FILES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/lib/libcrypto.a | ||
LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/include | ||
include $(PREBUILT_STATIC_LIBRARY) | ||
|
||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := ssl | ||
LOCAL_SRC_FILES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/lib/libssl.a | ||
LOCAL_EXPORT_C_INCLUDES := $(OPENSSL_PATH)/out/$(TARGET_ARCH_ABI)/include | ||
LOCAL_STATIC_LIBRARIES := crypto | ||
include $(PREBUILT_STATIC_LIBRARY) | ||
|
||
LOCAL_PATH := $(call my-dir) | ||
include $(CLEAR_VARS) | ||
LOCAL_MODULE := miniupnpc | ||
LOCAL_SRC_FILES := $(MINIUPNP_PATH)/miniupnpc/out/$(TARGET_ARCH_ABI)/lib/libminiupnpc.a | ||
LOCAL_EXPORT_C_INCLUDES := $(MINIUPNP_PATH)/miniupnpc/out/$(TARGET_ARCH_ABI)/include | ||
include $(PREBUILT_STATIC_LIBRARY) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
NDK_TOOLCHAIN_VERSION := clang | ||
APP_STL := c++_static | ||
|
||
# Enable c++17 extensions in source code | ||
APP_CPPFLAGS += -std=c++17 -fexceptions -frtti | ||
|
||
APP_CPPFLAGS += -DANDROID -D__ANDROID__ -DUSE_UPNP -Wno-deprecated-declarations | ||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a) | ||
APP_CPPFLAGS += -DANDROID_ARM7A | ||
endif | ||
|
||
IFADDRS_PATH = $(NDK_MODULE_PATH)/android-ifaddrs | ||
BOOST_PATH = $(NDK_MODULE_PATH)/boost | ||
MINIUPNP_PATH = $(NDK_MODULE_PATH)/miniupnp | ||
OPENSSL_PATH = $(NDK_MODULE_PATH)/openssl | ||
|
||
# don't change me | ||
I2PD_SRC_PATH = $(NDK_MODULE_PATH)/i2pd | ||
|
||
LIB_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd | ||
LIB_CLIENT_SRC_PATH = $(I2PD_SRC_PATH)/libi2pd_client | ||
LANG_SRC_PATH = $(I2PD_SRC_PATH)/i18n | ||
DAEMON_SRC_PATH = $(I2PD_SRC_PATH)/daemon |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
/* | ||
* Copyright (c) 2013-2022, The PurpleI2P Project | ||
* | ||
* This file is part of Purple i2pd project and licensed under BSD3 | ||
* | ||
* See full license text in LICENSE file at top of project tree | ||
*/ | ||
|
||
#include <iostream> | ||
#include <chrono> | ||
#include <thread> | ||
#include <exception> | ||
#include <boost/exception/diagnostic_information.hpp> | ||
#include <boost/exception_ptr.hpp> | ||
//#include "mainwindow.h" | ||
#include "FS.h" | ||
#include "DaemonAndroid.h" | ||
#include "Daemon.h" | ||
#include "I18N.h" | ||
|
||
namespace i2p | ||
{ | ||
namespace android | ||
{ | ||
std::string dataDir = ""; | ||
std::string language = ""; | ||
|
||
DaemonAndroidImpl::DaemonAndroidImpl () | ||
{ | ||
} | ||
|
||
DaemonAndroidImpl::~DaemonAndroidImpl () | ||
{ | ||
} | ||
|
||
bool DaemonAndroidImpl::init(int argc, char* argv[]) | ||
{ | ||
return Daemon.init(argc, argv); | ||
} | ||
|
||
void DaemonAndroidImpl::start() | ||
{ | ||
Daemon.start(); | ||
} | ||
|
||
void DaemonAndroidImpl::stop() | ||
{ | ||
Daemon.stop(); | ||
} | ||
|
||
void DaemonAndroidImpl::restart() | ||
{ | ||
stop(); | ||
start(); | ||
} | ||
|
||
void DaemonAndroidImpl::setDataDir(std::string path) | ||
{ | ||
Daemon.setDataDir(path); | ||
} | ||
|
||
static DaemonAndroidImpl daemon; | ||
static char* argv[1]={strdup("tmp")}; | ||
/** | ||
* returns error details if failed | ||
* returns "ok" if daemon initialized and started okay | ||
*/ | ||
std::string start(/*int argc, char* argv[]*/) | ||
{ | ||
try | ||
{ | ||
{ | ||
// make sure assets are ready before proceed | ||
i2p::fs::DetectDataDir(dataDir, false); | ||
int numAttempts = 0; | ||
do | ||
{ | ||
if (i2p::fs::Exists (i2p::fs::DataDirPath("assets.ready"))) break; // assets ready | ||
numAttempts++; | ||
std::this_thread::sleep_for (std::chrono::seconds(1)); // otherwise wait for 1 more second | ||
} | ||
while (numAttempts <= 10); // 10 seconds max | ||
|
||
// Set application directory | ||
daemon.setDataDir(dataDir); | ||
|
||
bool daemonInitSuccess = daemon.init(1, argv); | ||
if(!daemonInitSuccess) | ||
{ | ||
return "Daemon init failed"; | ||
} | ||
|
||
// Set webconsole language from application | ||
i2p::i18n::SetLanguage(language); | ||
|
||
daemon.start(); | ||
} | ||
} | ||
catch (boost::exception& ex) | ||
{ | ||
std::stringstream ss; | ||
ss << boost::diagnostic_information(ex); | ||
return ss.str(); | ||
} | ||
catch (std::exception& ex) | ||
{ | ||
std::stringstream ss; | ||
ss << ex.what(); | ||
return ss.str(); | ||
} | ||
catch(...) | ||
{ | ||
return "unknown exception"; | ||
} | ||
return "ok"; | ||
} | ||
|
||
void stop() | ||
{ | ||
daemon.stop(); | ||
} | ||
|
||
void SetDataDir(std::string jdataDir) | ||
{ | ||
dataDir = jdataDir; | ||
} | ||
|
||
std::string GetDataDir(void) | ||
{ | ||
return dataDir; | ||
} | ||
|
||
void SetLanguage(std::string jlanguage) | ||
{ | ||
language = jlanguage; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2013-2022, The PurpleI2P Project | ||
* | ||
* This file is part of Purple i2pd project and licensed under BSD3 | ||
* | ||
* See full license text in LICENSE file at top of project tree | ||
*/ | ||
|
||
#ifndef DAEMON_ANDROID_H | ||
#define DAEMON_ANDROID_H | ||
|
||
#include <string> | ||
|
||
namespace i2p | ||
{ | ||
namespace android | ||
{ | ||
class DaemonAndroidImpl | ||
{ | ||
public: | ||
|
||
DaemonAndroidImpl (); | ||
~DaemonAndroidImpl (); | ||
|
||
/** | ||
* @return success | ||
*/ | ||
bool init (int argc, char* argv[]); | ||
void start (); | ||
void stop (); | ||
void restart (); | ||
|
||
void setDataDir (std::string path); | ||
}; | ||
|
||
/** | ||
* returns "ok" if daemon init failed | ||
* returns errinfo if daemon initialized and started okay | ||
*/ | ||
std::string start (); | ||
|
||
void stop (); | ||
|
||
// set datadir received from jni | ||
void SetDataDir (std::string jdataDir); | ||
// get datadir | ||
std::string GetDataDir (void); | ||
// set webconsole language | ||
void SetLanguage (std::string jlanguage); | ||
} | ||
} | ||
|
||
#endif // DAEMON_ANDROID_H |
Oops, something went wrong.