From a41f1797851bcfc81e5fde2b57d91f3bfac241f8 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 31 Oct 2016 14:00:31 -0400 Subject: [PATCH 1/4] get home directory from EXTERNAL_STORAGE for andorid --- FS.cpp | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/FS.cpp b/FS.cpp index 84b30f21..74da7ee9 100644 --- a/FS.cpp +++ b/FS.cpp @@ -45,18 +45,18 @@ namespace fs { return; } #if defined(WIN32) || defined(_WIN32) - char localAppData[MAX_PATH]; - // check executable directory first - GetModuleFileName (NULL, localAppData, MAX_PATH); - auto execPath = boost::filesystem::path(localAppData).parent_path(); - // if config file exists in .exe's folder use it - if(boost::filesystem::exists(execPath/"i2pd.conf")) // TODO: magic string - dataDir = execPath.string (); - else - { - // otherwise %appdata% - SHGetFolderPath(NULL, CSIDL_APPDATA, 0, NULL, localAppData); - dataDir = std::string(localAppData) + "\\" + appName; + char localAppData[MAX_PATH]; + // check executable directory first + GetModuleFileName (NULL, localAppData, MAX_PATH); + auto execPath = boost::filesystem::path(localAppData).parent_path(); + // if config file exists in .exe's folder use it + if(boost::filesystem::exists(execPath/"i2pd.conf")) // TODO: magic string + dataDir = execPath.string (); + else + { + // otherwise %appdata% + SHGetFolderPath(NULL, CSIDL_APPDATA, 0, NULL, localAppData); + dataDir = std::string(localAppData) + "\\" + appName; } return; #elif defined(MAC_OSX) @@ -66,9 +66,11 @@ namespace fs { return; #else /* other unix */ #if defined(ANDROID) - if (boost::filesystem::exists("/sdcard")) + const char * ext = getenv("EXTERNAL_STORAGE"); + if (!ext) ext = "/sdcard"; + if (boost::filesystem::exists(ext)) { - dataDir = "/sdcard/" + appName; + dataDir = ext + appName; return; } // otherwise use /data/files From a4883cfa15cb316441c2537d5425520bce3f86f8 Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 31 Oct 2016 15:13:43 -0400 Subject: [PATCH 2/4] print tunnel peers in direct order --- Tunnel.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Tunnel.cpp b/Tunnel.cpp index 44d92d75..0c1b278a 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -184,10 +184,11 @@ namespace tunnel void Tunnel::PrintHops (std::stringstream& s) const { - for (auto& it: m_Hops) + // hops are in inverted order, we must print in direct order + for (auto it = m_Hops.rbegin (); it != m_Hops.rend (); it++) { s << " ⇒ "; - s << i2p::data::GetIdentHashAbbreviation (it->ident->GetIdentHash ()); + s << i2p::data::GetIdentHashAbbreviation ((*it)->ident->GetIdentHash ()); } } From b526718846421bc98db4fdaf6e0255aa197b610b Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 31 Oct 2016 15:42:50 -0400 Subject: [PATCH 3/4] show HTTP proxy as client tunnel --- ClientContext.h | 1 + HTTPServer.cpp | 9 +++++++++ I2PService.h | 1 + 3 files changed, 11 insertions(+) diff --git a/ClientContext.h b/ClientContext.h index 1a41acfc..d82058c6 100644 --- a/ClientContext.h +++ b/ClientContext.h @@ -110,6 +110,7 @@ namespace client const decltype(m_ServerTunnels)& GetServerTunnels () const { return m_ServerTunnels; }; const decltype(m_ClientForwards)& GetClientForwards () const { return m_ClientForwards; } const decltype(m_ServerForwards)& GetServerForwards () const { return m_ServerForwards; } + const i2p::proxy::HTTPProxy * GetHttpProxy () const { return m_HttpProxy; } }; extern ClientContext context; diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 890daf9e..99edf508 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -549,6 +549,15 @@ namespace http { s << i2p::client::context.GetAddressBook ().ToAddress(ident); s << "
\r\n"<< std::endl; } + auto httpProxy = i2p::client::context.GetHttpProxy (); + if (httpProxy) + { + auto& ident = httpProxy->GetLocalDestination ()->GetIdentHash(); + s << ""; + s << "HTTP Proxy" << " ⇐ "; + s << i2p::client::context.GetAddressBook ().ToAddress(ident); + s << "
\r\n"<< std::endl; + } s << "
\r\nServer Tunnels:
\r\n
\r\n"; for (auto& it: i2p::client::context.GetServerTunnels ()) { diff --git a/I2PService.h b/I2PService.h index 2df11909..59746a6f 100644 --- a/I2PService.h +++ b/I2PService.h @@ -38,6 +38,7 @@ namespace client } inline std::shared_ptr GetLocalDestination () { return m_LocalDestination; } + inline std::shared_ptr GetLocalDestination () const { return m_LocalDestination; } inline void SetLocalDestination (std::shared_ptr dest) { m_LocalDestination = dest; } void CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port = 0); From 3d4e2a275c5be14014fd54b1c1ccb5590366379a Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 31 Oct 2016 18:10:33 -0400 Subject: [PATCH 4/4] correct separator for android --- FS.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FS.cpp b/FS.cpp index 74da7ee9..64484b15 100644 --- a/FS.cpp +++ b/FS.cpp @@ -70,7 +70,7 @@ namespace fs { if (!ext) ext = "/sdcard"; if (boost::filesystem::exists(ext)) { - dataDir = ext + appName; + dataDir = std::string (ext) + "/" + appName; return; } // otherwise use /data/files