Merge branch 'master' of github.com:orignal/i2pd

pull/52/head
Meeh 10 years ago
commit f7b3e9c933

2
.gitignore vendored

@ -53,7 +53,6 @@ local.properties
[Dd]ebug/
[Rr]elease/
x64/
build/
[Bb]in/
[Oo]bj/
@ -200,7 +199,6 @@ $RECYCLE.BIN/
*.egg
*.egg-info
dist/
build/
eggs/
parts/
var/

@ -532,8 +532,9 @@ namespace data
void NetDb::Explore ()
{
auto outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel ();
auto inbound = i2p::tunnel::tunnels.GetNextInboundTunnel ();
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr;
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr;
if (outbound && inbound)
{
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();

@ -154,11 +154,14 @@ namespace tunnel
else
block.deliveryType = eDeliveryTypeLocal;
block.data = msg;
std::unique_lock<std::mutex> l(m_SendMutex);
m_Gateway.SendTunnelDataMsg (block);
}
void OutboundTunnel::SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs)
{
std::unique_lock<std::mutex> l(m_SendMutex);
for (auto& it : msgs)
m_Gateway.PutTunnelDataMsg (it);
m_Gateway.SendBuffer ();

@ -7,6 +7,7 @@
#include <vector>
#include <string>
#include <thread>
#include <mutex>
#include <cryptopp/modes.h>
#include <cryptopp/aes.h>
#include "Queue.h"
@ -83,6 +84,7 @@ namespace tunnel
private:
std::mutex m_SendMutex;
TunnelGateway m_Gateway;
};
@ -115,6 +117,7 @@ namespace tunnel
Tunnel * GetPendingTunnel (uint32_t replyMsgID);
InboundTunnel * GetNextInboundTunnel ();
OutboundTunnel * GetNextOutboundTunnel ();
TunnelPool * GetExploratoryPool () const { return m_ExploratoryPool; };
TransitTunnel * GetTransitTunnel (uint32_t tunnelID);
void AddTransitTunnel (TransitTunnel * tunnel);
void AddOutboundTunnel (OutboundTunnel * newTunnel);

@ -86,7 +86,22 @@ namespace tunnel
m_LastOutboundTunnel = tunnel;
return tunnel;
}
InboundTunnel * TunnelPool::GetNextInboundTunnel ()
{
return GetNextTunnel (m_InboundTunnels);
}
template<class TTunnels>
typename TTunnels::value_type TunnelPool::GetNextTunnel (TTunnels& tunnels)
{
if (tunnels.empty ()) return nullptr;
for (auto it: tunnels)
if (!it->IsFailed ())
return it;
return nullptr;
}
void TunnelPool::CreateTunnels ()
{
int num = m_InboundTunnels.size ();

@ -37,6 +37,7 @@ namespace tunnel
void TunnelExpired (OutboundTunnel * expiredTunnel);
std::vector<InboundTunnel *> GetInboundTunnels (int num) const;
OutboundTunnel * GetNextOutboundTunnel ();
InboundTunnel * GetNextInboundTunnel ();
const i2p::data::IdentHash& GetIdentHash () { return m_LocalDestination.GetIdentHash (); };
void TestTunnels ();
@ -46,6 +47,8 @@ namespace tunnel
void CreateInboundTunnel ();
void CreateOutboundTunnel ();
template<class TTunnels>
typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels);
private:

@ -0,0 +1,94 @@
cmake_minimum_required ( VERSION 2.8 )
project ( i2pd )
set ( SRC_DIR ".." )
set ( INC_DIR ".." )
add_definitions ( "-std=c++0x -Wall" )
set ( SOURCES
AddressBook.cpp
Garlic.cpp
HTTPServer.cpp
i2p.cpp
Identity.cpp
Log.cpp
NTCPSession.cpp
RouterContext.cpp
SSU.cpp
TransitTunnel.cpp
Tunnel.cpp
TunnelGateway.cpp
UPnP.cpp
base64.cpp
HTTPProxy.cpp
I2NPProtocol.cpp
LeaseSet.cpp
NetDb.cpp
Reseed.cpp
RouterInfo.cpp
Streaming.cpp
Transports.cpp
TunnelEndpoint.cpp
TunnelPool.cpp
util.cpp
)
set ( HEADERS
AddressBook.h
Garlic.h
HTTPServer.h
Identity.h
Log.h
NTCPSession.h
RouterContext.h
SSU.h
TransitTunnel.h
Tunnel.h
TunnelGateway.h
UPnP.h
base64.h
HTTPProxy.h
I2NPProtocol.h
LeaseSet.h
NetDb.h
Reseed.h
RouterInfo.h
Streaming.h
Transports.h
TunnelEndpoint.h
TunnelPool.h
util.h
)
source_group ("Header Files" FILES ${HEADERS})
source_group ("Source Files" FILES ${SOURCES})
find_package ( Threads REQUIRED )
find_package ( Boost COMPONENTS system filesystem regex program_options REQUIRED )
set ( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules" )
find_package ( CryptoPP REQUIRED )
include_directories ( ${Boost_INCLUDE_DIRS} ${CryptoPP_INCLUDE_DIRS})
unset ( TMP )
foreach ( src ${SOURCES} )
list ( APPEND TMP "${SRC_DIR}/${src}" )
endforeach ()
set ( SOURCES ${TMP} )
unset ( TMP )
foreach ( hdr ${HEADERS} )
list ( APPEND TMP "${INC_DIR}/${hdr}" )
endforeach ()
set ( HEADERS ${TMP} )
add_executable ( ${PROJECT_NAME} WIN32 ${HEADERS} ${SOURCES} )
target_link_libraries( ${PROJECT_NAME} ${Boost_LIBRARIES} ${CryptoPP_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} )

@ -0,0 +1,28 @@
# Find Crypto++ library
#
# Output variables :
# CryptoPP_FOUND
# CryptoPP_INCLUDE_DIRS
# CryptoPP_LIBRARIES
#
FIND_PATH( CryptoPP_INCLUDE_DIR cryptopp/dsa.h )
FIND_LIBRARY( CryptoPP_LIBRARY NAMES cryptopp )
# handle the QUIETLY and REQUIRED arguments and set CRYPTOPP_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CryptoPP DEFAULT_MSG CryptoPP_LIBRARY CryptoPP_INCLUDE_DIR)
set ( CryptoPP_FOUND FALSE )
if ( ${CRYPTOPP_FOUND} )
set ( CryptoPP_FOUND TRUE )
set ( CryptoPP_INCLUDE_DIRS ${CryptoPP_INCLUDE_DIR} )
set ( CryptoPP_LIBRARIES ${CryptoPP_LIBRARY} )
endif ()
MARK_AS_ADVANCED(CryptoPP_INCLUDE_DIR CryptoPP_LIBRARY)
Loading…
Cancel
Save