mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 08:00:38 +03:00
Merge branch 'master' of github.com:orignal/i2pd
This commit is contained in:
commit
f7b3e9c933
2
.gitignore
vendored
2
.gitignore
vendored
@ -53,7 +53,6 @@ local.properties
|
|||||||
[Dd]ebug/
|
[Dd]ebug/
|
||||||
[Rr]elease/
|
[Rr]elease/
|
||||||
x64/
|
x64/
|
||||||
build/
|
|
||||||
[Bb]in/
|
[Bb]in/
|
||||||
[Oo]bj/
|
[Oo]bj/
|
||||||
|
|
||||||
@ -200,7 +199,6 @@ $RECYCLE.BIN/
|
|||||||
*.egg
|
*.egg
|
||||||
*.egg-info
|
*.egg-info
|
||||||
dist/
|
dist/
|
||||||
build/
|
|
||||||
eggs/
|
eggs/
|
||||||
parts/
|
parts/
|
||||||
var/
|
var/
|
||||||
|
@ -532,8 +532,9 @@ namespace data
|
|||||||
|
|
||||||
void NetDb::Explore ()
|
void NetDb::Explore ()
|
||||||
{
|
{
|
||||||
auto outbound = i2p::tunnel::tunnels.GetNextOutboundTunnel ();
|
auto exploratoryPool = i2p::tunnel::tunnels.GetExploratoryPool ();
|
||||||
auto inbound = i2p::tunnel::tunnels.GetNextInboundTunnel ();
|
auto outbound = exploratoryPool ? exploratoryPool->GetNextOutboundTunnel () : nullptr;
|
||||||
|
auto inbound = exploratoryPool ? exploratoryPool->GetNextInboundTunnel () : nullptr;
|
||||||
if (outbound && inbound)
|
if (outbound && inbound)
|
||||||
{
|
{
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
|
@ -154,11 +154,14 @@ namespace tunnel
|
|||||||
else
|
else
|
||||||
block.deliveryType = eDeliveryTypeLocal;
|
block.deliveryType = eDeliveryTypeLocal;
|
||||||
block.data = msg;
|
block.data = msg;
|
||||||
|
|
||||||
|
std::unique_lock<std::mutex> l(m_SendMutex);
|
||||||
m_Gateway.SendTunnelDataMsg (block);
|
m_Gateway.SendTunnelDataMsg (block);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OutboundTunnel::SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs)
|
void OutboundTunnel::SendTunnelDataMsg (std::vector<TunnelMessageBlock> msgs)
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_SendMutex);
|
||||||
for (auto& it : msgs)
|
for (auto& it : msgs)
|
||||||
m_Gateway.PutTunnelDataMsg (it);
|
m_Gateway.PutTunnelDataMsg (it);
|
||||||
m_Gateway.SendBuffer ();
|
m_Gateway.SendBuffer ();
|
||||||
|
3
Tunnel.h
3
Tunnel.h
@ -7,6 +7,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include <mutex>
|
||||||
#include <cryptopp/modes.h>
|
#include <cryptopp/modes.h>
|
||||||
#include <cryptopp/aes.h>
|
#include <cryptopp/aes.h>
|
||||||
#include "Queue.h"
|
#include "Queue.h"
|
||||||
@ -83,6 +84,7 @@ namespace tunnel
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
std::mutex m_SendMutex;
|
||||||
TunnelGateway m_Gateway;
|
TunnelGateway m_Gateway;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -115,6 +117,7 @@ namespace tunnel
|
|||||||
Tunnel * GetPendingTunnel (uint32_t replyMsgID);
|
Tunnel * GetPendingTunnel (uint32_t replyMsgID);
|
||||||
InboundTunnel * GetNextInboundTunnel ();
|
InboundTunnel * GetNextInboundTunnel ();
|
||||||
OutboundTunnel * GetNextOutboundTunnel ();
|
OutboundTunnel * GetNextOutboundTunnel ();
|
||||||
|
TunnelPool * GetExploratoryPool () const { return m_ExploratoryPool; };
|
||||||
TransitTunnel * GetTransitTunnel (uint32_t tunnelID);
|
TransitTunnel * GetTransitTunnel (uint32_t tunnelID);
|
||||||
void AddTransitTunnel (TransitTunnel * tunnel);
|
void AddTransitTunnel (TransitTunnel * tunnel);
|
||||||
void AddOutboundTunnel (OutboundTunnel * newTunnel);
|
void AddOutboundTunnel (OutboundTunnel * newTunnel);
|
||||||
|
@ -86,7 +86,22 @@ namespace tunnel
|
|||||||
m_LastOutboundTunnel = tunnel;
|
m_LastOutboundTunnel = tunnel;
|
||||||
return 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 ()
|
void TunnelPool::CreateTunnels ()
|
||||||
{
|
{
|
||||||
int num = m_InboundTunnels.size ();
|
int num = m_InboundTunnels.size ();
|
||||||
|
@ -37,6 +37,7 @@ namespace tunnel
|
|||||||
void TunnelExpired (OutboundTunnel * expiredTunnel);
|
void TunnelExpired (OutboundTunnel * expiredTunnel);
|
||||||
std::vector<InboundTunnel *> GetInboundTunnels (int num) const;
|
std::vector<InboundTunnel *> GetInboundTunnels (int num) const;
|
||||||
OutboundTunnel * GetNextOutboundTunnel ();
|
OutboundTunnel * GetNextOutboundTunnel ();
|
||||||
|
InboundTunnel * GetNextInboundTunnel ();
|
||||||
const i2p::data::IdentHash& GetIdentHash () { return m_LocalDestination.GetIdentHash (); };
|
const i2p::data::IdentHash& GetIdentHash () { return m_LocalDestination.GetIdentHash (); };
|
||||||
|
|
||||||
void TestTunnels ();
|
void TestTunnels ();
|
||||||
@ -46,6 +47,8 @@ namespace tunnel
|
|||||||
|
|
||||||
void CreateInboundTunnel ();
|
void CreateInboundTunnel ();
|
||||||
void CreateOutboundTunnel ();
|
void CreateOutboundTunnel ();
|
||||||
|
template<class TTunnels>
|
||||||
|
typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
94
build/CMakeLists.txt
Normal file
94
build/CMakeLists.txt
Normal file
@ -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} )
|
28
build/cmake_modules/FindCryptoPP.cmake
Normal file
28
build/cmake_modules/FindCryptoPP.cmake
Normal file
@ -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…
Reference in New Issue
Block a user