From e5f5f96771237a8a9f937fdfc6136917e12eea56 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Tue, 1 Nov 2016 10:46:07 -0400 Subject: [PATCH] merge webui code --- Event.h | 1 - Tunnel.cpp | 2 -- Tunnel.h | 20 +++++++++++++++++--- TunnelBase.h | 2 +- build/CMakeLists.txt | 4 +--- docs/building/requirements.md | 1 + docs/building/unix.md | 3 +++ 7 files changed, 23 insertions(+), 10 deletions(-) diff --git a/Event.h b/Event.h index be57d7bf..7998a15b 100644 --- a/Event.h +++ b/Event.h @@ -31,7 +31,6 @@ namespace i2p extern EventCore core; } } - void EmitEvent(const EventType & ev); #endif diff --git a/Tunnel.cpp b/Tunnel.cpp index 77e003d1..59dfc519 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -598,7 +598,6 @@ namespace tunnel hop = hop->next; } } - if(pool) pool->OnTunnelBuildResult(tunnel, eBuildResultTimeout); EmitTunnelEvent("tunnel.state", tunnel.get(), eTunnelStateBuildFailed); // delete it = pendingTunnels.erase (it); @@ -610,7 +609,6 @@ namespace tunnel case eTunnelStateBuildFailed: LogPrint (eLogDebug, "Tunnel: pending build request ", it->first, " failed, deleted"); - if(pool) pool->OnTunnelBuildResult(tunnel, eBuildResultRejected); EmitTunnelEvent("tunnel.state", tunnel.get(), eTunnelStateBuildFailed); it = pendingTunnels.erase (it); diff --git a/Tunnel.h b/Tunnel.h index 115adf00..54917d49 100644 --- a/Tunnel.h +++ b/Tunnel.h @@ -31,7 +31,10 @@ namespace tunnel { #ifdef WITH_EVENTS EmitEvent({{"type", ev}, {"tid", std::to_string(t->GetTunnelID())}}); -#endif +#else + (void) ev; + (void) t; +#endif } template @@ -39,6 +42,10 @@ namespace tunnel { #ifdef WITH_EVENTS EmitEvent({{"type", ev}, {"tid", std::to_string(t->GetTunnelID())}, {"value", std::to_string(val)}, {"inbound", std::to_string(t->IsInbound())}}); +#else + (void) ev; + (void) t; + (void) val; #endif } @@ -47,6 +54,10 @@ namespace tunnel { #ifdef WITH_EVENTS EmitEvent({{"type", ev}, {"tid", std::to_string(t->GetTunnelID())}, {"value", val}, {"inbound", std::to_string(t->IsInbound())}}); +#else + (void) ev; + (void) t; + (void) val; #endif } @@ -94,7 +105,8 @@ namespace tunnel bool IsFailed () const { return m_State == eTunnelStateFailed; }; bool IsRecreated () const { return m_IsRecreated; }; void SetIsRecreated () { m_IsRecreated = true; }; - + virtual bool IsInbound() const = 0; + std::shared_ptr GetTunnelPool () const { return m_Pool; }; void SetTunnelPool (std::shared_ptr pool) { m_Pool = pool; }; @@ -134,6 +146,8 @@ namespace tunnel // implements TunnelBase void HandleTunnelDataMsg (std::shared_ptr tunnelMsg); + + bool IsInbound() const { return false; } private: @@ -150,7 +164,7 @@ namespace tunnel void HandleTunnelDataMsg (std::shared_ptr msg); virtual size_t GetNumReceivedBytes () const { return m_Endpoint.GetNumReceivedBytes (); }; void Print (std::stringstream& s) const; - + bool IsInbound() const { return true; } private: TunnelEndpoint m_Endpoint; diff --git a/TunnelBase.h b/TunnelBase.h index bec06400..1b4e1e1f 100644 --- a/TunnelBase.h +++ b/TunnelBase.h @@ -48,7 +48,7 @@ namespace tunnel uint32_t GetCreationTime () const { return m_CreationTime; }; void SetCreationTime (uint32_t t) { m_CreationTime = t; }; - + private: uint32_t m_TunnelID, m_NextTunnelID; diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt index 80c84eef..5291a82f 100644 --- a/build/CMakeLists.txt +++ b/build/CMakeLists.txt @@ -60,15 +60,13 @@ set (LIBI2PD_SRC "${CMAKE_SOURCE_DIR}/Signature.cpp" "${CMAKE_SOURCE_DIR}/Timestamp.cpp" "${CMAKE_SOURCE_DIR}/api.cpp" + "${CMAKE_SOURCE_DIR}/Event.cpp" ) if (WITH_WEBSOCKETS) add_definitions(-DWITH_EVENTS) find_package(websocketpp REQUIRED) endif () -if (WITH_WEBSOCKETS) - list (APPEND LIBI2PD_SRC "${CMAKE_SOURCE_DIR}/Event.cpp") -endif () if (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR MSYS) list (APPEND LIBI2PD_SRC "${CMAKE_SOURCE_DIR}/I2PEndian.cpp") diff --git a/docs/building/requirements.md b/docs/building/requirements.md index 8712a03d..1bb163e1 100644 --- a/docs/building/requirements.md +++ b/docs/building/requirements.md @@ -12,3 +12,4 @@ Optional tools: * cmake >= 2.8 (or 3.3+ if you want to use precompiled headers on windows) * miniupnp library (for upnp support) +* [websocketpp](https://github.com/zaphoyd/websocketpp/) (for websocket ui) diff --git a/docs/building/unix.md b/docs/building/unix.md index b7a638f5..17623159 100644 --- a/docs/building/unix.md +++ b/docs/building/unix.md @@ -46,6 +46,9 @@ Available CMake options(each option has a form of `=`, for more info * `WITH_AESNI` build with AES-NI support (ON/OFF) * `WITH_HARDENING` enable hardening features (ON/OFF) (gcc only) * `WITH_PCH` use pre-compiled header (experimental, speeds up build) +* `WITH_I2LUA` used when building i2lua +* `WITH_WEBSOCKETS` enable websocket server + Also there is `-L` flag for CMake that could be used to list current cached options: