mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
merge webui code
This commit is contained in:
parent
d4a0076aba
commit
e5f5f96771
1
Event.h
1
Event.h
@ -31,7 +31,6 @@ namespace i2p
|
|||||||
extern EventCore core;
|
extern EventCore core;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EmitEvent(const EventType & ev);
|
void EmitEvent(const EventType & ev);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -598,7 +598,6 @@ namespace tunnel
|
|||||||
hop = hop->next;
|
hop = hop->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(pool) pool->OnTunnelBuildResult(tunnel, eBuildResultTimeout);
|
|
||||||
EmitTunnelEvent("tunnel.state", tunnel.get(), eTunnelStateBuildFailed);
|
EmitTunnelEvent("tunnel.state", tunnel.get(), eTunnelStateBuildFailed);
|
||||||
// delete
|
// delete
|
||||||
it = pendingTunnels.erase (it);
|
it = pendingTunnels.erase (it);
|
||||||
@ -610,7 +609,6 @@ namespace tunnel
|
|||||||
case eTunnelStateBuildFailed:
|
case eTunnelStateBuildFailed:
|
||||||
LogPrint (eLogDebug, "Tunnel: pending build request ", it->first, " failed, deleted");
|
LogPrint (eLogDebug, "Tunnel: pending build request ", it->first, " failed, deleted");
|
||||||
|
|
||||||
if(pool) pool->OnTunnelBuildResult(tunnel, eBuildResultRejected);
|
|
||||||
EmitTunnelEvent("tunnel.state", tunnel.get(), eTunnelStateBuildFailed);
|
EmitTunnelEvent("tunnel.state", tunnel.get(), eTunnelStateBuildFailed);
|
||||||
|
|
||||||
it = pendingTunnels.erase (it);
|
it = pendingTunnels.erase (it);
|
||||||
|
20
Tunnel.h
20
Tunnel.h
@ -31,7 +31,10 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
#ifdef WITH_EVENTS
|
#ifdef WITH_EVENTS
|
||||||
EmitEvent({{"type", ev}, {"tid", std::to_string(t->GetTunnelID())}});
|
EmitEvent({{"type", ev}, {"tid", std::to_string(t->GetTunnelID())}});
|
||||||
#endif
|
#else
|
||||||
|
(void) ev;
|
||||||
|
(void) t;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename TunnelT, typename T>
|
template<typename TunnelT, typename T>
|
||||||
@ -39,6 +42,10 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
#ifdef WITH_EVENTS
|
#ifdef WITH_EVENTS
|
||||||
EmitEvent({{"type", ev}, {"tid", std::to_string(t->GetTunnelID())}, {"value", std::to_string(val)}, {"inbound", std::to_string(t->IsInbound())}});
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -47,6 +54,10 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
#ifdef WITH_EVENTS
|
#ifdef WITH_EVENTS
|
||||||
EmitEvent({{"type", ev}, {"tid", std::to_string(t->GetTunnelID())}, {"value", val}, {"inbound", std::to_string(t->IsInbound())}});
|
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
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +105,8 @@ namespace tunnel
|
|||||||
bool IsFailed () const { return m_State == eTunnelStateFailed; };
|
bool IsFailed () const { return m_State == eTunnelStateFailed; };
|
||||||
bool IsRecreated () const { return m_IsRecreated; };
|
bool IsRecreated () const { return m_IsRecreated; };
|
||||||
void SetIsRecreated () { m_IsRecreated = true; };
|
void SetIsRecreated () { m_IsRecreated = true; };
|
||||||
|
virtual bool IsInbound() const = 0;
|
||||||
|
|
||||||
std::shared_ptr<TunnelPool> GetTunnelPool () const { return m_Pool; };
|
std::shared_ptr<TunnelPool> GetTunnelPool () const { return m_Pool; };
|
||||||
void SetTunnelPool (std::shared_ptr<TunnelPool> pool) { m_Pool = pool; };
|
void SetTunnelPool (std::shared_ptr<TunnelPool> pool) { m_Pool = pool; };
|
||||||
|
|
||||||
@ -134,6 +146,8 @@ namespace tunnel
|
|||||||
|
|
||||||
// implements TunnelBase
|
// implements TunnelBase
|
||||||
void HandleTunnelDataMsg (std::shared_ptr<const i2p::I2NPMessage> tunnelMsg);
|
void HandleTunnelDataMsg (std::shared_ptr<const i2p::I2NPMessage> tunnelMsg);
|
||||||
|
|
||||||
|
bool IsInbound() const { return false; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
@ -150,7 +164,7 @@ namespace tunnel
|
|||||||
void HandleTunnelDataMsg (std::shared_ptr<const I2NPMessage> msg);
|
void HandleTunnelDataMsg (std::shared_ptr<const I2NPMessage> msg);
|
||||||
virtual size_t GetNumReceivedBytes () const { return m_Endpoint.GetNumReceivedBytes (); };
|
virtual size_t GetNumReceivedBytes () const { return m_Endpoint.GetNumReceivedBytes (); };
|
||||||
void Print (std::stringstream& s) const;
|
void Print (std::stringstream& s) const;
|
||||||
|
bool IsInbound() const { return true; }
|
||||||
private:
|
private:
|
||||||
|
|
||||||
TunnelEndpoint m_Endpoint;
|
TunnelEndpoint m_Endpoint;
|
||||||
|
@ -48,7 +48,7 @@ namespace tunnel
|
|||||||
|
|
||||||
uint32_t GetCreationTime () const { return m_CreationTime; };
|
uint32_t GetCreationTime () const { return m_CreationTime; };
|
||||||
void SetCreationTime (uint32_t t) { m_CreationTime = t; };
|
void SetCreationTime (uint32_t t) { m_CreationTime = t; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
uint32_t m_TunnelID, m_NextTunnelID;
|
uint32_t m_TunnelID, m_NextTunnelID;
|
||||||
|
@ -60,15 +60,13 @@ set (LIBI2PD_SRC
|
|||||||
"${CMAKE_SOURCE_DIR}/Signature.cpp"
|
"${CMAKE_SOURCE_DIR}/Signature.cpp"
|
||||||
"${CMAKE_SOURCE_DIR}/Timestamp.cpp"
|
"${CMAKE_SOURCE_DIR}/Timestamp.cpp"
|
||||||
"${CMAKE_SOURCE_DIR}/api.cpp"
|
"${CMAKE_SOURCE_DIR}/api.cpp"
|
||||||
|
"${CMAKE_SOURCE_DIR}/Event.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (WITH_WEBSOCKETS)
|
if (WITH_WEBSOCKETS)
|
||||||
add_definitions(-DWITH_EVENTS)
|
add_definitions(-DWITH_EVENTS)
|
||||||
find_package(websocketpp REQUIRED)
|
find_package(websocketpp REQUIRED)
|
||||||
endif ()
|
endif ()
|
||||||
if (WITH_WEBSOCKETS)
|
|
||||||
list (APPEND LIBI2PD_SRC "${CMAKE_SOURCE_DIR}/Event.cpp")
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR MSYS)
|
if (CMAKE_SYSTEM_NAME STREQUAL "Windows" OR MSYS)
|
||||||
list (APPEND LIBI2PD_SRC "${CMAKE_SOURCE_DIR}/I2PEndian.cpp")
|
list (APPEND LIBI2PD_SRC "${CMAKE_SOURCE_DIR}/I2PEndian.cpp")
|
||||||
|
@ -12,3 +12,4 @@ Optional tools:
|
|||||||
|
|
||||||
* cmake >= 2.8 (or 3.3+ if you want to use precompiled headers on windows)
|
* cmake >= 2.8 (or 3.3+ if you want to use precompiled headers on windows)
|
||||||
* miniupnp library (for upnp support)
|
* miniupnp library (for upnp support)
|
||||||
|
* [websocketpp](https://github.com/zaphoyd/websocketpp/) (for websocket ui)
|
||||||
|
@ -46,6 +46,9 @@ Available CMake options(each option has a form of `<key>=<value>`, for more info
|
|||||||
* `WITH_AESNI` build with AES-NI support (ON/OFF)
|
* `WITH_AESNI` build with AES-NI support (ON/OFF)
|
||||||
* `WITH_HARDENING` enable hardening features (ON/OFF) (gcc only)
|
* `WITH_HARDENING` enable hardening features (ON/OFF) (gcc only)
|
||||||
* `WITH_PCH` use pre-compiled header (experimental, speeds up build)
|
* `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:
|
Also there is `-L` flag for CMake that could be used to list current cached options:
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user