mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-07 06:09:42 +00:00
Compare commits
10 Commits
v0.3.0-1st
...
0.3.0-home
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
335de27095 | ||
|
|
fa461b1254 | ||
|
|
81c63b0c30 | ||
|
|
dcefe7d221 | ||
|
|
ed3aaefe96 | ||
|
|
6042aefd17 | ||
|
|
1c3f70056a | ||
|
|
d8b9968aed | ||
|
|
8a357ac46c | ||
|
|
5187701af1 |
@@ -710,7 +710,7 @@ namespace util
|
|||||||
if (it.second && it.second->IsEstablished ())
|
if (it.second && it.second->IsEstablished ())
|
||||||
{
|
{
|
||||||
// incoming connection doesn't have remote RI
|
// incoming connection doesn't have remote RI
|
||||||
bool outgoing = it.second->GetRemoteRouter ();
|
auto outgoing = it.second->GetRemoteRouter ();
|
||||||
if (outgoing) s << "-->";
|
if (outgoing) s << "-->";
|
||||||
s << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase64 ().substr (0, 4) << ": "
|
s << it.second->GetRemoteIdentity ().GetIdentHash ().ToBase64 ().substr (0, 4) << ": "
|
||||||
<< it.second->GetSocket ().remote_endpoint().address ().to_string ();
|
<< it.second->GetSocket ().remote_endpoint().address ().to_string ();
|
||||||
@@ -727,7 +727,7 @@ namespace util
|
|||||||
for (auto it: ssuServer->GetSessions ())
|
for (auto it: ssuServer->GetSessions ())
|
||||||
{
|
{
|
||||||
// incoming connections don't have remote router
|
// incoming connections don't have remote router
|
||||||
bool outgoing = it.second->GetRemoteRouter ();
|
auto outgoing = it.second->GetRemoteRouter ();
|
||||||
auto endpoint = it.second->GetRemoteEndpoint ();
|
auto endpoint = it.second->GetRemoteEndpoint ();
|
||||||
if (outgoing) s << "-->";
|
if (outgoing) s << "-->";
|
||||||
s << endpoint.address ().to_string () << ":" << endpoint.port ();
|
s << endpoint.address ().to_string () << ":" << endpoint.port ();
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ LIBS =
|
|||||||
# Found no good way to detect it from command line. TODO: Might be some osx sysinfo magic
|
# Found no good way to detect it from command line. TODO: Might be some osx sysinfo magic
|
||||||
CXXFLAGS += -maes -DAESNI
|
CXXFLAGS += -maes -DAESNI
|
||||||
|
|
||||||
|
|
||||||
|
${PREFIX}:
|
||||||
|
|
||||||
|
install: all
|
||||||
|
mkdir -p ${PREFIX}/
|
||||||
|
cp -r i2p ${PREFIX}/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Apple Mac OSX
|
# Apple Mac OSX
|
||||||
UNAME_S := $(shell uname -s)
|
UNAME_S := $(shell uname -s)
|
||||||
ifeq ($(UNAME_S),Darwin)
|
ifeq ($(UNAME_S),Darwin)
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace i2p
|
|||||||
{
|
{
|
||||||
namespace transport
|
namespace transport
|
||||||
{
|
{
|
||||||
NTCPSession::NTCPSession (boost::asio::io_service& service, const i2p::data::RouterInfo * in_RemoteRouter):
|
NTCPSession::NTCPSession (boost::asio::io_service& service, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter):
|
||||||
TransportSession (in_RemoteRouter), m_Socket (service),
|
TransportSession (in_RemoteRouter), m_Socket (service),
|
||||||
m_TerminationTimer (service), m_IsEstablished (false), m_ReceiveBufferOffset (0),
|
m_TerminationTimer (service), m_IsEstablished (false), m_ReceiveBufferOffset (0),
|
||||||
m_NextMessage (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0)
|
m_NextMessage (nullptr), m_NumSentBytes (0), m_NumReceivedBytes (0)
|
||||||
@@ -597,8 +597,8 @@ namespace transport
|
|||||||
|
|
||||||
|
|
||||||
NTCPClient::NTCPClient (boost::asio::io_service& service, const boost::asio::ip::address& address,
|
NTCPClient::NTCPClient (boost::asio::io_service& service, const boost::asio::ip::address& address,
|
||||||
int port, const i2p::data::RouterInfo& in_RouterInfo):
|
int port, std::shared_ptr<const i2p::data::RouterInfo> in_RouterInfo):
|
||||||
NTCPSession (service, &in_RouterInfo), m_Endpoint (address, port)
|
NTCPSession (service, in_RouterInfo), m_Endpoint (address, port)
|
||||||
{
|
{
|
||||||
Connect ();
|
Connect ();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace transport
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NTCPSession (boost::asio::io_service& service, const i2p::data::RouterInfo * in_RemoteRouter = nullptr);
|
NTCPSession (boost::asio::io_service& service, std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter = nullptr);
|
||||||
~NTCPSession ();
|
~NTCPSession ();
|
||||||
|
|
||||||
boost::asio::ip::tcp::socket& GetSocket () { return m_Socket; };
|
boost::asio::ip::tcp::socket& GetSocket () { return m_Socket; };
|
||||||
@@ -146,7 +146,7 @@ namespace transport
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
NTCPClient (boost::asio::io_service& service, const boost::asio::ip::address& address, int port, const i2p::data::RouterInfo& in_RouterInfo);
|
NTCPClient (boost::asio::io_service& service, const boost::asio::ip::address& address, int port, std::shared_ptr<const i2p::data::RouterInfo> in_RouterInfo);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
69
NetDb.cpp
69
NetDb.cpp
@@ -21,7 +21,7 @@ namespace i2p
|
|||||||
{
|
{
|
||||||
namespace data
|
namespace data
|
||||||
{
|
{
|
||||||
I2NPMessage * RequestedDestination::CreateRequestMessage (const RouterInfo * router,
|
I2NPMessage * RequestedDestination::CreateRequestMessage (std::shared_ptr<const RouterInfo> router,
|
||||||
const i2p::tunnel::InboundTunnel * replyTunnel)
|
const i2p::tunnel::InboundTunnel * replyTunnel)
|
||||||
{
|
{
|
||||||
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (m_Destination,
|
I2NPMessage * msg = i2p::CreateDatabaseLookupMsg (m_Destination,
|
||||||
@@ -168,23 +168,26 @@ namespace data
|
|||||||
void NetDb::AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len)
|
void NetDb::AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len)
|
||||||
{
|
{
|
||||||
DeleteRequestedDestination (ident);
|
DeleteRequestedDestination (ident);
|
||||||
auto it = m_RouterInfos.find(ident);
|
auto r = FindRouter (ident);
|
||||||
if (it != m_RouterInfos.end ())
|
if (r)
|
||||||
{
|
{
|
||||||
auto ts = it->second->GetTimestamp ();
|
auto ts = r->GetTimestamp ();
|
||||||
it->second->Update (buf, len);
|
r->Update (buf, len);
|
||||||
if (it->second->GetTimestamp () > ts)
|
if (r->GetTimestamp () > ts)
|
||||||
LogPrint ("RouterInfo updated");
|
LogPrint ("RouterInfo updated");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LogPrint ("New RouterInfo added");
|
LogPrint ("New RouterInfo added");
|
||||||
auto r = std::make_shared<RouterInfo> (buf, len);
|
auto newRouter = std::make_shared<RouterInfo> (buf, len);
|
||||||
m_RouterInfos[r->GetIdentHash ()] = r;
|
{
|
||||||
if (r->IsFloodfill ())
|
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||||
|
m_RouterInfos[newRouter->GetIdentHash ()] = newRouter;
|
||||||
|
}
|
||||||
|
if (newRouter->IsFloodfill ())
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||||
m_Floodfills.push_back (r);
|
m_Floodfills.push_back (newRouter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -209,11 +212,12 @@ namespace data
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RouterInfo * NetDb::FindRouter (const IdentHash& ident) const
|
std::shared_ptr<RouterInfo> NetDb::FindRouter (const IdentHash& ident) const
|
||||||
{
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||||
auto it = m_RouterInfos.find (ident);
|
auto it = m_RouterInfos.find (ident);
|
||||||
if (it != m_RouterInfos.end ())
|
if (it != m_RouterInfos.end ())
|
||||||
return it->second.get ();
|
return it->second;
|
||||||
else
|
else
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
@@ -354,18 +358,36 @@ namespace data
|
|||||||
|
|
||||||
if (it.second->IsUnreachable ())
|
if (it.second->IsUnreachable ())
|
||||||
{
|
{
|
||||||
|
// delete RI file
|
||||||
if (boost::filesystem::exists (GetFilePath (fullDirectory, it.second.get ())))
|
if (boost::filesystem::exists (GetFilePath (fullDirectory, it.second.get ())))
|
||||||
{
|
{
|
||||||
boost::filesystem::remove (GetFilePath (fullDirectory, it.second.get ()));
|
boost::filesystem::remove (GetFilePath (fullDirectory, it.second.get ()));
|
||||||
deletedCount++;
|
deletedCount++;
|
||||||
}
|
}
|
||||||
|
// delete from floodfills list
|
||||||
|
if (it.second->IsFloodfill ())
|
||||||
|
{
|
||||||
|
std::unique_lock<std::mutex> l(m_FloodfillsMutex);
|
||||||
|
m_Floodfills.remove (it.second);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (count > 0)
|
if (count > 0)
|
||||||
LogPrint (count," new/updated routers saved");
|
LogPrint (count," new/updated routers saved");
|
||||||
if (deletedCount > 0)
|
if (deletedCount > 0)
|
||||||
|
{
|
||||||
LogPrint (deletedCount," routers deleted");
|
LogPrint (deletedCount," routers deleted");
|
||||||
|
// clean up RouterInfos table
|
||||||
|
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||||
|
for (auto it = m_RouterInfos.begin (); it != m_RouterInfos.end ();)
|
||||||
|
{
|
||||||
|
if (it->second->IsUnreachable ())
|
||||||
|
it = m_RouterInfos.erase (it);
|
||||||
|
else
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void NetDb::RequestDestination (const IdentHash& destination, bool isLeaseSet, i2p::tunnel::TunnelPool * pool)
|
void NetDb::RequestDestination (const IdentHash& destination, bool isLeaseSet, i2p::tunnel::TunnelPool * pool)
|
||||||
@@ -611,7 +633,7 @@ namespace data
|
|||||||
LogPrint ("Requested RouterInfo ", key, " found");
|
LogPrint ("Requested RouterInfo ", key, " found");
|
||||||
router->LoadBuffer ();
|
router->LoadBuffer ();
|
||||||
if (router->GetBuffer ())
|
if (router->GetBuffer ())
|
||||||
replyMsg = CreateDatabaseStoreMsg (router);
|
replyMsg = CreateDatabaseStoreMsg (router.get ());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!replyMsg)
|
if (!replyMsg)
|
||||||
@@ -633,7 +655,7 @@ namespace data
|
|||||||
excludedRouters.insert (excluded);
|
excludedRouters.insert (excluded);
|
||||||
excluded += 32;
|
excluded += 32;
|
||||||
}
|
}
|
||||||
replyMsg = CreateDatabaseSearchReply (buf, GetClosestFloodfill (buf, excludedRouters));
|
replyMsg = CreateDatabaseSearchReply (buf, GetClosestFloodfill (buf, excludedRouters).get ());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
excluded += numExcluded*32; // we don't care about exluded
|
excluded += numExcluded*32; // we don't care about exluded
|
||||||
@@ -697,9 +719,9 @@ namespace data
|
|||||||
rnd.GenerateBlock (randomHash, 32);
|
rnd.GenerateBlock (randomHash, 32);
|
||||||
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true, exploratoryPool);
|
RequestedDestination * dest = CreateRequestedDestination (IdentHash (randomHash), false, true, exploratoryPool);
|
||||||
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
|
auto floodfill = GetClosestFloodfill (randomHash, dest->GetExcludedPeers ());
|
||||||
if (floodfill && !floodfills.count (floodfill)) // request floodfill only once
|
if (floodfill && !floodfills.count (floodfill.get ())) // request floodfill only once
|
||||||
{
|
{
|
||||||
floodfills.insert (floodfill);
|
floodfills.insert (floodfill.get ());
|
||||||
if (throughTunnels)
|
if (throughTunnels)
|
||||||
{
|
{
|
||||||
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
msgs.push_back (i2p::tunnel::TunnelMessageBlock
|
||||||
@@ -787,22 +809,22 @@ namespace data
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetRandomRouter (const RouterInfo * compatibleWith) const
|
std::shared_ptr<const RouterInfo> NetDb::GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
[compatibleWith](std::shared_ptr<const RouterInfo> router)->bool
|
[compatibleWith](std::shared_ptr<const RouterInfo> router)->bool
|
||||||
{
|
{
|
||||||
return !router->IsHidden () && router.get () != compatibleWith &&
|
return !router->IsHidden () && router != compatibleWith &&
|
||||||
router->IsCompatible (*compatibleWith);
|
router->IsCompatible (*compatibleWith);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> NetDb::GetHighBandwidthRandomRouter (const RouterInfo * compatibleWith) const
|
std::shared_ptr<const RouterInfo> NetDb::GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const
|
||||||
{
|
{
|
||||||
return GetRandomRouter (
|
return GetRandomRouter (
|
||||||
[compatibleWith](std::shared_ptr<const RouterInfo> router)->bool
|
[compatibleWith](std::shared_ptr<const RouterInfo> router)->bool
|
||||||
{
|
{
|
||||||
return !router->IsHidden () && router.get () != compatibleWith &&
|
return !router->IsHidden () && router != compatibleWith &&
|
||||||
router->IsCompatible (*compatibleWith) && (router->GetCaps () & RouterInfo::eHighBandwidth);
|
router->IsCompatible (*compatibleWith) && (router->GetCaps () & RouterInfo::eHighBandwidth);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -815,6 +837,7 @@ namespace data
|
|||||||
for (int j = 0; j < 2; j++)
|
for (int j = 0; j < 2; j++)
|
||||||
{
|
{
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
std::unique_lock<std::mutex> l(m_RouterInfosMutex);
|
||||||
for (auto it: m_RouterInfos)
|
for (auto it: m_RouterInfos)
|
||||||
{
|
{
|
||||||
if (i >= ind)
|
if (i >= ind)
|
||||||
@@ -836,10 +859,10 @@ namespace data
|
|||||||
if (msg) m_Queue.Put (msg);
|
if (msg) m_Queue.Put (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const RouterInfo * NetDb::GetClosestFloodfill (const IdentHash& destination,
|
std::shared_ptr<const RouterInfo> NetDb::GetClosestFloodfill (const IdentHash& destination,
|
||||||
const std::set<IdentHash>& excluded) const
|
const std::set<IdentHash>& excluded) const
|
||||||
{
|
{
|
||||||
RouterInfo * r = nullptr;
|
std::shared_ptr<const RouterInfo> r;
|
||||||
XORMetric minMetric;
|
XORMetric minMetric;
|
||||||
IdentHash destKey = CreateRoutingKey (destination);
|
IdentHash destKey = CreateRoutingKey (destination);
|
||||||
minMetric.SetMax ();
|
minMetric.SetMax ();
|
||||||
@@ -852,7 +875,7 @@ namespace data
|
|||||||
if (m < minMetric)
|
if (m < minMetric)
|
||||||
{
|
{
|
||||||
minMetric = m;
|
minMetric = m;
|
||||||
r = it.get ();
|
r = it;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
21
NetDb.h
21
NetDb.h
@@ -4,7 +4,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <vector>
|
#include <list>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
@@ -27,19 +27,19 @@ namespace data
|
|||||||
RequestedDestination (const IdentHash& destination, bool isLeaseSet,
|
RequestedDestination (const IdentHash& destination, bool isLeaseSet,
|
||||||
bool isExploratory = false, i2p::tunnel::TunnelPool * pool = nullptr):
|
bool isExploratory = false, i2p::tunnel::TunnelPool * pool = nullptr):
|
||||||
m_Destination (destination), m_IsLeaseSet (isLeaseSet), m_IsExploratory (isExploratory),
|
m_Destination (destination), m_IsLeaseSet (isLeaseSet), m_IsExploratory (isExploratory),
|
||||||
m_Pool (pool), m_LastRouter (nullptr), m_CreationTime (0) {};
|
m_Pool (pool), m_CreationTime (0) {};
|
||||||
|
|
||||||
const IdentHash& GetDestination () const { return m_Destination; };
|
const IdentHash& GetDestination () const { return m_Destination; };
|
||||||
int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); };
|
int GetNumExcludedPeers () const { return m_ExcludedPeers.size (); };
|
||||||
const std::set<IdentHash>& GetExcludedPeers () { return m_ExcludedPeers; };
|
const std::set<IdentHash>& GetExcludedPeers () { return m_ExcludedPeers; };
|
||||||
void ClearExcludedPeers ();
|
void ClearExcludedPeers ();
|
||||||
const RouterInfo * GetLastRouter () const { return m_LastRouter; };
|
std::shared_ptr<const RouterInfo> GetLastRouter () const { return m_LastRouter; };
|
||||||
i2p::tunnel::TunnelPool * GetTunnelPool () { return m_Pool; };
|
i2p::tunnel::TunnelPool * GetTunnelPool () { return m_Pool; };
|
||||||
bool IsExploratory () const { return m_IsExploratory; };
|
bool IsExploratory () const { return m_IsExploratory; };
|
||||||
bool IsLeaseSet () const { return m_IsLeaseSet; };
|
bool IsLeaseSet () const { return m_IsLeaseSet; };
|
||||||
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
|
bool IsExcluded (const IdentHash& ident) const { return m_ExcludedPeers.count (ident); };
|
||||||
uint64_t GetCreationTime () const { return m_CreationTime; };
|
uint64_t GetCreationTime () const { return m_CreationTime; };
|
||||||
I2NPMessage * CreateRequestMessage (const RouterInfo * router, const i2p::tunnel::InboundTunnel * replyTunnel);
|
I2NPMessage * CreateRequestMessage (std::shared_ptr<const RouterInfo>, const i2p::tunnel::InboundTunnel * replyTunnel);
|
||||||
I2NPMessage * CreateRequestMessage (const IdentHash& floodfill);
|
I2NPMessage * CreateRequestMessage (const IdentHash& floodfill);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -48,7 +48,7 @@ namespace data
|
|||||||
bool m_IsLeaseSet, m_IsExploratory;
|
bool m_IsLeaseSet, m_IsExploratory;
|
||||||
i2p::tunnel::TunnelPool * m_Pool;
|
i2p::tunnel::TunnelPool * m_Pool;
|
||||||
std::set<IdentHash> m_ExcludedPeers;
|
std::set<IdentHash> m_ExcludedPeers;
|
||||||
const RouterInfo * m_LastRouter;
|
std::shared_ptr<const RouterInfo> m_LastRouter;
|
||||||
uint64_t m_CreationTime;
|
uint64_t m_CreationTime;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -64,7 +64,7 @@ namespace data
|
|||||||
|
|
||||||
void AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len);
|
void AddRouterInfo (const IdentHash& ident, const uint8_t * buf, int len);
|
||||||
void AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len, i2p::tunnel::InboundTunnel * from);
|
void AddLeaseSet (const IdentHash& ident, const uint8_t * buf, int len, i2p::tunnel::InboundTunnel * from);
|
||||||
RouterInfo * FindRouter (const IdentHash& ident) const;
|
std::shared_ptr<RouterInfo> FindRouter (const IdentHash& ident) const;
|
||||||
LeaseSet * FindLeaseSet (const IdentHash& destination) const;
|
LeaseSet * FindLeaseSet (const IdentHash& destination) const;
|
||||||
|
|
||||||
void PublishLeaseSet (const LeaseSet * leaseSet, i2p::tunnel::TunnelPool * pool);
|
void PublishLeaseSet (const LeaseSet * leaseSet, i2p::tunnel::TunnelPool * pool);
|
||||||
@@ -76,8 +76,8 @@ namespace data
|
|||||||
void HandleDatabaseLookupMsg (I2NPMessage * msg);
|
void HandleDatabaseLookupMsg (I2NPMessage * msg);
|
||||||
|
|
||||||
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter () const;
|
||||||
std::shared_ptr<const RouterInfo> GetRandomRouter (const RouterInfo * compatibleWith) const;
|
std::shared_ptr<const RouterInfo> GetRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
||||||
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (const RouterInfo * compatibleWith) const;
|
std::shared_ptr<const RouterInfo> GetHighBandwidthRandomRouter (std::shared_ptr<const RouterInfo> compatibleWith) const;
|
||||||
void SetUnreachable (const IdentHash& ident, bool unreachable);
|
void SetUnreachable (const IdentHash& ident, bool unreachable);
|
||||||
|
|
||||||
void PostI2NPMsg (I2NPMessage * msg);
|
void PostI2NPMsg (I2NPMessage * msg);
|
||||||
@@ -95,7 +95,7 @@ namespace data
|
|||||||
void Run (); // exploratory thread
|
void Run (); // exploratory thread
|
||||||
void Explore (int numDestinations);
|
void Explore (int numDestinations);
|
||||||
void Publish ();
|
void Publish ();
|
||||||
const RouterInfo * GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
std::shared_ptr<const RouterInfo> GetClosestFloodfill (const IdentHash& destination, const std::set<IdentHash>& excluded) const;
|
||||||
void ManageLeaseSets ();
|
void ManageLeaseSets ();
|
||||||
|
|
||||||
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
RequestedDestination * CreateRequestedDestination (const IdentHash& dest,
|
||||||
@@ -109,9 +109,10 @@ namespace data
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
std::map<IdentHash, LeaseSet *> m_LeaseSets;
|
std::map<IdentHash, LeaseSet *> m_LeaseSets;
|
||||||
|
mutable std::mutex m_RouterInfosMutex;
|
||||||
std::map<IdentHash, std::shared_ptr<RouterInfo> > m_RouterInfos;
|
std::map<IdentHash, std::shared_ptr<RouterInfo> > m_RouterInfos;
|
||||||
mutable std::mutex m_FloodfillsMutex;
|
mutable std::mutex m_FloodfillsMutex;
|
||||||
std::vector<std::shared_ptr<RouterInfo> > m_Floodfills;
|
std::list<std::shared_ptr<RouterInfo> > m_Floodfills;
|
||||||
std::mutex m_RequestedDestinationsMutex;
|
std::mutex m_RequestedDestinationsMutex;
|
||||||
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
|
std::map<IdentHash, RequestedDestination *> m_RequestedDestinations;
|
||||||
|
|
||||||
|
|||||||
78
SAM.cpp
78
SAM.cpp
@@ -26,21 +26,18 @@ namespace client
|
|||||||
SAMSocket::~SAMSocket ()
|
SAMSocket::~SAMSocket ()
|
||||||
{
|
{
|
||||||
if (m_Stream)
|
if (m_Stream)
|
||||||
{
|
|
||||||
m_Stream->Close ();
|
|
||||||
i2p::stream::DeleteStream (m_Stream);
|
i2p::stream::DeleteStream (m_Stream);
|
||||||
m_Stream = nullptr;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::Terminate ()
|
void SAMSocket::Terminate ()
|
||||||
{
|
{
|
||||||
if (m_Stream)
|
if (m_Stream)
|
||||||
{
|
|
||||||
m_Stream->Close ();
|
m_Stream->Close ();
|
||||||
i2p::stream::DeleteStream (m_Stream);
|
|
||||||
m_Stream = nullptr;
|
// TODO: make this swap atomic
|
||||||
}
|
auto session = m_Session;
|
||||||
|
m_Session = nullptr;
|
||||||
|
|
||||||
switch (m_SocketType)
|
switch (m_SocketType)
|
||||||
{
|
{
|
||||||
case eSAMSocketTypeSession:
|
case eSAMSocketTypeSession:
|
||||||
@@ -48,16 +45,16 @@ namespace client
|
|||||||
break;
|
break;
|
||||||
case eSAMSocketTypeStream:
|
case eSAMSocketTypeStream:
|
||||||
{
|
{
|
||||||
if (m_Session)
|
if (session)
|
||||||
m_Session->sockets.remove (this);
|
session->sockets.remove (shared_from_this ());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case eSAMSocketTypeAcceptor:
|
case eSAMSocketTypeAcceptor:
|
||||||
{
|
{
|
||||||
if (m_Session)
|
if (session)
|
||||||
{
|
{
|
||||||
m_Session->sockets.remove (this);
|
session->sockets.remove (shared_from_this ());
|
||||||
m_Session->localDestination->StopAcceptingStreams ();
|
session->localDestination->StopAcceptingStreams ();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -65,13 +62,12 @@ namespace client
|
|||||||
;
|
;
|
||||||
}
|
}
|
||||||
m_Socket.close ();
|
m_Socket.close ();
|
||||||
// delete this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::ReceiveHandshake ()
|
void SAMSocket::ReceiveHandshake ()
|
||||||
{
|
{
|
||||||
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind(&SAMSocket::HandleHandshakeReceived, this,
|
boost::bind(&SAMSocket::HandleHandshakeReceived, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,7 +87,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
// TODO: check version
|
// TODO: check version
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (SAM_HANDSHAKE_REPLY, strlen (SAM_HANDSHAKE_REPLY)), boost::asio::transfer_all (),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (SAM_HANDSHAKE_REPLY, strlen (SAM_HANDSHAKE_REPLY)), boost::asio::transfer_all (),
|
||||||
boost::bind(&SAMSocket::HandleHandshakeReplySent, this,
|
boost::bind(&SAMSocket::HandleHandshakeReplySent, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -113,7 +109,7 @@ namespace client
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind(&SAMSocket::HandleMessage, this,
|
boost::bind(&SAMSocket::HandleMessage, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -122,7 +118,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
if (!m_IsSilent || m_SocketType == eSAMSocketTypeAcceptor)
|
if (!m_IsSilent || m_SocketType == eSAMSocketTypeAcceptor)
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (msg, len), boost::asio::transfer_all (),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (msg, len), boost::asio::transfer_all (),
|
||||||
boost::bind(&SAMSocket::HandleMessageReplySent, this,
|
boost::bind(&SAMSocket::HandleMessageReplySent, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, close));
|
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred, close));
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -228,7 +224,7 @@ namespace client
|
|||||||
if (style == SAM_VALUE_DATAGRAM)
|
if (style == SAM_VALUE_DATAGRAM)
|
||||||
{
|
{
|
||||||
auto dest = m_Session->localDestination->CreateDatagramDestination ();
|
auto dest = m_Session->localDestination->CreateDatagramDestination ();
|
||||||
dest->SetReceiver (std::bind (&SAMSocket::HandleI2PDatagramReceive, this,
|
dest->SetReceiver (std::bind (&SAMSocket::HandleI2PDatagramReceive, shared_from_this (),
|
||||||
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3));
|
||||||
}
|
}
|
||||||
SendSessionCreateReplyOk ();
|
SendSessionCreateReplyOk ();
|
||||||
@@ -237,7 +233,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
m_Timer.async_wait (boost::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
||||||
this, boost::asio::placeholders::error));
|
shared_from_this (), boost::asio::placeholders::error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -254,7 +250,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_SESSION_READINESS_CHECK_INTERVAL));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
m_Timer.async_wait (boost::bind (&SAMSocket::HandleSessionReadinessCheckTimer,
|
||||||
this, boost::asio::placeholders::error));
|
shared_from_this (), boost::asio::placeholders::error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -299,7 +295,7 @@ namespace client
|
|||||||
i2p::data::netdb.RequestDestination (dest.GetIdentHash (), true, m_Session->localDestination->GetTunnelPool ());
|
i2p::data::netdb.RequestDestination (dest.GetIdentHash (), true, m_Session->localDestination->GetTunnelPool ());
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_CONNECT_TIMEOUT));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_CONNECT_TIMEOUT));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleStreamDestinationRequestTimer,
|
m_Timer.async_wait (boost::bind (&SAMSocket::HandleStreamDestinationRequestTimer,
|
||||||
this, boost::asio::placeholders::error, dest.GetIdentHash ()));
|
shared_from_this (), boost::asio::placeholders::error, dest.GetIdentHash ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -309,7 +305,7 @@ namespace client
|
|||||||
void SAMSocket::Connect (const i2p::data::LeaseSet& remote)
|
void SAMSocket::Connect (const i2p::data::LeaseSet& remote)
|
||||||
{
|
{
|
||||||
m_SocketType = eSAMSocketTypeStream;
|
m_SocketType = eSAMSocketTypeStream;
|
||||||
m_Session->sockets.push_back (this);
|
m_Session->sockets.push_back (shared_from_this ());
|
||||||
m_Stream = m_Session->localDestination->CreateStream (remote);
|
m_Stream = m_Session->localDestination->CreateStream (remote);
|
||||||
m_Stream->Send ((uint8_t *)m_Buffer, 0); // connect
|
m_Stream->Send ((uint8_t *)m_Buffer, 0); // connect
|
||||||
I2PReceive ();
|
I2PReceive ();
|
||||||
@@ -366,8 +362,8 @@ namespace client
|
|||||||
if (!m_Session->localDestination->IsAcceptingStreams ())
|
if (!m_Session->localDestination->IsAcceptingStreams ())
|
||||||
{
|
{
|
||||||
m_SocketType = eSAMSocketTypeAcceptor;
|
m_SocketType = eSAMSocketTypeAcceptor;
|
||||||
m_Session->sockets.push_back (this);
|
m_Session->sockets.push_back (shared_from_this ());
|
||||||
m_Session->localDestination->AcceptStreams (std::bind (&SAMSocket::HandleI2PAccept, this, std::placeholders::_1));
|
m_Session->localDestination->AcceptStreams (std::bind (&SAMSocket::HandleI2PAccept, shared_from_this (), std::placeholders::_1));
|
||||||
SendMessageReply (SAM_STREAM_STATUS_OK, strlen(SAM_STREAM_STATUS_OK), false);
|
SendMessageReply (SAM_STREAM_STATUS_OK, strlen(SAM_STREAM_STATUS_OK), false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -422,7 +418,7 @@ namespace client
|
|||||||
i2p::data::netdb.RequestDestination (ident, true, m_Session->localDestination->GetTunnelPool ());
|
i2p::data::netdb.RequestDestination (ident, true, m_Session->localDestination->GetTunnelPool ());
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_NAMING_LOOKUP_TIMEOUT));
|
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_NAMING_LOOKUP_TIMEOUT));
|
||||||
m_Timer.async_wait (boost::bind (&SAMSocket::HandleNamingLookupDestinationRequestTimer,
|
m_Timer.async_wait (boost::bind (&SAMSocket::HandleNamingLookupDestinationRequestTimer,
|
||||||
this, boost::asio::placeholders::error, ident));
|
shared_from_this (), boost::asio::placeholders::error, ident));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -475,7 +471,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Socket.async_read_some (boost::asio::buffer(m_Buffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind((m_SocketType == eSAMSocketTypeSession) ? &SAMSocket::HandleMessage : &SAMSocket::HandleReceived,
|
boost::bind((m_SocketType == eSAMSocketTypeSession) ? &SAMSocket::HandleMessage : &SAMSocket::HandleReceived,
|
||||||
this, boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
shared_from_this (), boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
void SAMSocket::HandleReceived (const boost::system::error_code& ecode, std::size_t bytes_transferred)
|
||||||
@@ -498,7 +494,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
if (m_Stream)
|
if (m_Stream)
|
||||||
m_Stream->AsyncReceive (boost::asio::buffer (m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE),
|
m_Stream->AsyncReceive (boost::asio::buffer (m_StreamBuffer, SAM_SOCKET_BUFFER_SIZE),
|
||||||
boost::bind (&SAMSocket::HandleI2PReceive, this,
|
boost::bind (&SAMSocket::HandleI2PReceive, shared_from_this (),
|
||||||
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred),
|
boost::asio::placeholders::error, boost::asio::placeholders::bytes_transferred),
|
||||||
SAM_SOCKET_CONNECTION_MAX_IDLE);
|
SAM_SOCKET_CONNECTION_MAX_IDLE);
|
||||||
}
|
}
|
||||||
@@ -514,7 +510,7 @@ namespace client
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, bytes_transferred),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, bytes_transferred),
|
||||||
boost::bind (&SAMSocket::HandleWriteI2PData, this, boost::asio::placeholders::error));
|
boost::bind (&SAMSocket::HandleWriteI2PData, shared_from_this (), boost::asio::placeholders::error));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -567,7 +563,7 @@ namespace client
|
|||||||
{
|
{
|
||||||
memcpy (m_StreamBuffer + l2, buf, len);
|
memcpy (m_StreamBuffer + l2, buf, len);
|
||||||
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, len + l2),
|
boost::asio::async_write (m_Socket, boost::asio::buffer (m_StreamBuffer, len + l2),
|
||||||
boost::bind (&SAMSocket::HandleWriteI2PData, this, boost::asio::placeholders::error));
|
boost::bind (&SAMSocket::HandleWriteI2PData, shared_from_this (), boost::asio::placeholders::error));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
LogPrint (eLogWarning, "Datagram size ", len," exceeds buffer");
|
LogPrint (eLogWarning, "Datagram size ", len," exceeds buffer");
|
||||||
@@ -576,15 +572,13 @@ namespace client
|
|||||||
SAMBridge::SAMBridge (int port):
|
SAMBridge::SAMBridge (int port):
|
||||||
m_IsRunning (false), m_Thread (nullptr),
|
m_IsRunning (false), m_Thread (nullptr),
|
||||||
m_Acceptor (m_Service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
|
m_Acceptor (m_Service, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), port)),
|
||||||
m_DatagramEndpoint (boost::asio::ip::udp::v4 (), port-1), m_DatagramSocket (m_Service, m_DatagramEndpoint),
|
m_DatagramEndpoint (boost::asio::ip::udp::v4 (), port-1), m_DatagramSocket (m_Service, m_DatagramEndpoint)
|
||||||
m_NewSocket (nullptr)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
SAMBridge::~SAMBridge ()
|
SAMBridge::~SAMBridge ()
|
||||||
{
|
{
|
||||||
Stop ();
|
Stop ();
|
||||||
delete m_NewSocket;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMBridge::Start ()
|
void SAMBridge::Start ()
|
||||||
@@ -624,24 +618,20 @@ namespace client
|
|||||||
|
|
||||||
void SAMBridge::Accept ()
|
void SAMBridge::Accept ()
|
||||||
{
|
{
|
||||||
m_NewSocket = new SAMSocket (*this);
|
auto newSocket = std::make_shared<SAMSocket> (*this);
|
||||||
m_Acceptor.async_accept (m_NewSocket->GetSocket (), boost::bind (&SAMBridge::HandleAccept, this,
|
m_Acceptor.async_accept (newSocket->GetSocket (), boost::bind (&SAMBridge::HandleAccept, this,
|
||||||
boost::asio::placeholders::error));
|
boost::asio::placeholders::error, newSocket));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMBridge::HandleAccept(const boost::system::error_code& ecode)
|
void SAMBridge::HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<SAMSocket> socket)
|
||||||
{
|
{
|
||||||
if (!ecode)
|
if (!ecode)
|
||||||
{
|
{
|
||||||
LogPrint ("New SAM connection from ", m_NewSocket->GetSocket ().remote_endpoint ());
|
LogPrint ("New SAM connection from ", socket->GetSocket ().remote_endpoint ());
|
||||||
m_NewSocket->ReceiveHandshake ();
|
socket->ReceiveHandshake ();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
LogPrint ("SAM accept error: ", ecode.message ());
|
LogPrint ("SAM accept error: ", ecode.message ());
|
||||||
delete m_NewSocket;
|
|
||||||
m_NewSocket = nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ecode != boost::asio::error::operation_aborted)
|
if (ecode != boost::asio::error::operation_aborted)
|
||||||
Accept ();
|
Accept ();
|
||||||
@@ -680,8 +670,6 @@ namespace client
|
|||||||
auto it = m_Sessions.find (id);
|
auto it = m_Sessions.find (id);
|
||||||
if (it != m_Sessions.end ())
|
if (it != m_Sessions.end ())
|
||||||
{
|
{
|
||||||
for (auto it1 : it->second.sockets)
|
|
||||||
delete it1;
|
|
||||||
it->second.sockets.clear ();
|
it->second.sockets.clear ();
|
||||||
it->second.localDestination->Stop ();
|
it->second.localDestination->Stop ();
|
||||||
m_Sessions.erase (it);
|
m_Sessions.erase (it);
|
||||||
|
|||||||
10
SAM.h
10
SAM.h
@@ -7,6 +7,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
#include <memory>
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "LeaseSet.h"
|
#include "LeaseSet.h"
|
||||||
@@ -39,7 +40,7 @@ namespace client
|
|||||||
const char SAM_DEST_REPLY_I2P_ERROR[] = "DEST REPLY RESULT=I2P_ERROR\n";
|
const char SAM_DEST_REPLY_I2P_ERROR[] = "DEST REPLY RESULT=I2P_ERROR\n";
|
||||||
const char SAM_NAMING_LOOKUP[] = "NAMING LOOKUP";
|
const char SAM_NAMING_LOOKUP[] = "NAMING LOOKUP";
|
||||||
const char SAM_NAMING_REPLY[] = "NAMING REPLY RESULT=OK NAME=ME VALUE=%s\n";
|
const char SAM_NAMING_REPLY[] = "NAMING REPLY RESULT=OK NAME=ME VALUE=%s\n";
|
||||||
const char SAM_DATAGRAM_RECEIVED[] = "DATAGRAM_RECEIVED DESTINATION=%s SIZE=%i\n";
|
const char SAM_DATAGRAM_RECEIVED[] = "DATAGRAM_RECEIVED DESTINATION=%s SIZE=%lu\n";
|
||||||
const char SAM_NAMING_REPLY_INVALID_KEY[] = "NAMING REPLY RESULT=INVALID_KEY NAME=%s\n";
|
const char SAM_NAMING_REPLY_INVALID_KEY[] = "NAMING REPLY RESULT=INVALID_KEY NAME=%s\n";
|
||||||
const char SAM_NAMING_REPLY_KEY_NOT_FOUND[] = "NAMING REPLY RESULT=INVALID_KEY_NOT_FOUND NAME=%s\n";
|
const char SAM_NAMING_REPLY_KEY_NOT_FOUND[] = "NAMING REPLY RESULT=INVALID_KEY_NOT_FOUND NAME=%s\n";
|
||||||
const char SAM_PARAM_STYLE[] = "STYLE";
|
const char SAM_PARAM_STYLE[] = "STYLE";
|
||||||
@@ -64,7 +65,7 @@ namespace client
|
|||||||
|
|
||||||
class SAMBridge;
|
class SAMBridge;
|
||||||
class SAMSession;
|
class SAMSession;
|
||||||
class SAMSocket
|
class SAMSocket: public std::enable_shared_from_this<SAMSocket>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
@@ -122,7 +123,7 @@ namespace client
|
|||||||
struct SAMSession
|
struct SAMSession
|
||||||
{
|
{
|
||||||
ClientDestination * localDestination;
|
ClientDestination * localDestination;
|
||||||
std::list<SAMSocket *> sockets;
|
std::list<std::shared_ptr<SAMSocket> > sockets;
|
||||||
};
|
};
|
||||||
|
|
||||||
class SAMBridge
|
class SAMBridge
|
||||||
@@ -145,7 +146,7 @@ namespace client
|
|||||||
void Run ();
|
void Run ();
|
||||||
|
|
||||||
void Accept ();
|
void Accept ();
|
||||||
void HandleAccept(const boost::system::error_code& ecode);
|
void HandleAccept(const boost::system::error_code& ecode, std::shared_ptr<SAMSocket> socket);
|
||||||
|
|
||||||
void ReceiveDatagram ();
|
void ReceiveDatagram ();
|
||||||
void HandleReceivedDatagram (const boost::system::error_code& ecode, std::size_t bytes_transferred);
|
void HandleReceivedDatagram (const boost::system::error_code& ecode, std::size_t bytes_transferred);
|
||||||
@@ -158,7 +159,6 @@ namespace client
|
|||||||
boost::asio::ip::tcp::acceptor m_Acceptor;
|
boost::asio::ip::tcp::acceptor m_Acceptor;
|
||||||
boost::asio::ip::udp::endpoint m_DatagramEndpoint, m_SenderEndpoint;
|
boost::asio::ip::udp::endpoint m_DatagramEndpoint, m_SenderEndpoint;
|
||||||
boost::asio::ip::udp::socket m_DatagramSocket;
|
boost::asio::ip::udp::socket m_DatagramSocket;
|
||||||
SAMSocket * m_NewSocket;
|
|
||||||
std::mutex m_SessionsMutex;
|
std::mutex m_SessionsMutex;
|
||||||
std::map<std::string, SAMSession> m_Sessions;
|
std::map<std::string, SAMSession> m_Sessions;
|
||||||
uint8_t m_DatagramReceiveBuffer[i2p::datagram::MAX_DATAGRAM_SIZE+1];
|
uint8_t m_DatagramReceiveBuffer[i2p::datagram::MAX_DATAGRAM_SIZE+1];
|
||||||
|
|||||||
6
SSU.cpp
6
SSU.cpp
@@ -141,7 +141,7 @@ namespace transport
|
|||||||
session->ProcessNextMessage (buf, bytes_transferred, from);
|
session->ProcessNextMessage (buf, bytes_transferred, from);
|
||||||
}
|
}
|
||||||
|
|
||||||
SSUSession * SSUServer::FindSession (const i2p::data::RouterInfo * router)
|
SSUSession * SSUServer::FindSession (const i2p::data::RouterInfo * router) const
|
||||||
{
|
{
|
||||||
if (!router) return nullptr;
|
if (!router) return nullptr;
|
||||||
auto address = router->GetSSUAddress (true); // v4 only
|
auto address = router->GetSSUAddress (true); // v4 only
|
||||||
@@ -155,7 +155,7 @@ namespace transport
|
|||||||
return FindSession (boost::asio::ip::udp::endpoint (address->host, address->port));
|
return FindSession (boost::asio::ip::udp::endpoint (address->host, address->port));
|
||||||
}
|
}
|
||||||
|
|
||||||
SSUSession * SSUServer::FindSession (const boost::asio::ip::udp::endpoint& e)
|
SSUSession * SSUServer::FindSession (const boost::asio::ip::udp::endpoint& e) const
|
||||||
{
|
{
|
||||||
auto it = m_Sessions.find (e);
|
auto it = m_Sessions.find (e);
|
||||||
if (it != m_Sessions.end ())
|
if (it != m_Sessions.end ())
|
||||||
@@ -164,7 +164,7 @@ namespace transport
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
SSUSession * SSUServer::GetSession (const i2p::data::RouterInfo * router, bool peerTest)
|
SSUSession * SSUServer::GetSession (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest)
|
||||||
{
|
{
|
||||||
SSUSession * session = nullptr;
|
SSUSession * session = nullptr;
|
||||||
if (router)
|
if (router)
|
||||||
|
|||||||
6
SSU.h
6
SSU.h
@@ -31,9 +31,9 @@ namespace transport
|
|||||||
~SSUServer ();
|
~SSUServer ();
|
||||||
void Start ();
|
void Start ();
|
||||||
void Stop ();
|
void Stop ();
|
||||||
SSUSession * GetSession (const i2p::data::RouterInfo * router, bool peerTest = false);
|
SSUSession * GetSession (std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest = false);
|
||||||
SSUSession * FindSession (const i2p::data::RouterInfo * router);
|
SSUSession * FindSession (const i2p::data::RouterInfo * router) const;
|
||||||
SSUSession * FindSession (const boost::asio::ip::udp::endpoint& e);
|
SSUSession * FindSession (const boost::asio::ip::udp::endpoint& e) const;
|
||||||
SSUSession * GetRandomEstablishedSession (const SSUSession * excluded);
|
SSUSession * GetRandomEstablishedSession (const SSUSession * excluded);
|
||||||
void DeleteSession (SSUSession * session);
|
void DeleteSession (SSUSession * session);
|
||||||
void DeleteAllSessions ();
|
void DeleteAllSessions ();
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ namespace i2p
|
|||||||
namespace transport
|
namespace transport
|
||||||
{
|
{
|
||||||
SSUSession::SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
|
SSUSession::SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
|
||||||
const i2p::data::RouterInfo * router, bool peerTest ): TransportSession (router),
|
std::shared_ptr<const i2p::data::RouterInfo> router, bool peerTest ): TransportSession (router),
|
||||||
m_Server (server), m_RemoteEndpoint (remoteEndpoint),
|
m_Server (server), m_RemoteEndpoint (remoteEndpoint),
|
||||||
m_Timer (m_Server.GetService ()), m_PeerTest (peerTest),
|
m_Timer (m_Server.GetService ()), m_PeerTest (peerTest),
|
||||||
m_State (eSessionStateUnknown), m_IsSessionKey (false), m_RelayTag (0),
|
m_State (eSessionStateUnknown), m_IsSessionKey (false), m_RelayTag (0),
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ namespace transport
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
|
SSUSession (SSUServer& server, boost::asio::ip::udp::endpoint& remoteEndpoint,
|
||||||
const i2p::data::RouterInfo * router = nullptr, bool peerTest = false);
|
std::shared_ptr<const i2p::data::RouterInfo> router = nullptr, bool peerTest = false);
|
||||||
void ProcessNextMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
void ProcessNextMessage (uint8_t * buf, size_t len, const boost::asio::ip::udp::endpoint& senderEndpoint);
|
||||||
~SSUSession ();
|
~SSUSession ();
|
||||||
|
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <memory>
|
||||||
#include "Identity.h"
|
#include "Identity.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ namespace transport
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
TransportSession (const i2p::data::RouterInfo * in_RemoteRouter):
|
TransportSession (std::shared_ptr<const i2p::data::RouterInfo> in_RemoteRouter):
|
||||||
m_RemoteRouter (in_RemoteRouter), m_DHKeysPair (nullptr)
|
m_RemoteRouter (in_RemoteRouter), m_DHKeysPair (nullptr)
|
||||||
{
|
{
|
||||||
if (m_RemoteRouter)
|
if (m_RemoteRouter)
|
||||||
@@ -60,12 +61,12 @@ namespace transport
|
|||||||
|
|
||||||
virtual ~TransportSession () { delete m_DHKeysPair; };
|
virtual ~TransportSession () { delete m_DHKeysPair; };
|
||||||
|
|
||||||
const i2p::data::RouterInfo * GetRemoteRouter () { return m_RemoteRouter; };
|
std::shared_ptr<const i2p::data::RouterInfo> GetRemoteRouter () { return m_RemoteRouter; };
|
||||||
const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; };
|
const i2p::data::IdentityEx& GetRemoteIdentity () { return m_RemoteIdentity; };
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
const i2p::data::RouterInfo * m_RemoteRouter;
|
std::shared_ptr<const i2p::data::RouterInfo> m_RemoteRouter;
|
||||||
i2p::data::IdentityEx m_RemoteIdentity;
|
i2p::data::IdentityEx m_RemoteIdentity;
|
||||||
DHKeysPair * m_DHKeysPair; // X - for client and Y - for server
|
DHKeysPair * m_DHKeysPair; // X - for client and Y - for server
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -277,10 +277,10 @@ namespace transport
|
|||||||
session->SendI2NPMessage (msg);
|
session->SendI2NPMessage (msg);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
RouterInfo * r = netdb.FindRouter (ident);
|
auto r = netdb.FindRouter (ident);
|
||||||
if (r)
|
if (r)
|
||||||
{
|
{
|
||||||
auto ssuSession = m_SSUServer ? m_SSUServer->FindSession (r) : nullptr;
|
auto ssuSession = m_SSUServer ? m_SSUServer->FindSession (r.get ()) : nullptr;
|
||||||
if (ssuSession)
|
if (ssuSession)
|
||||||
ssuSession->SendI2NPMessage (msg);
|
ssuSession->SendI2NPMessage (msg);
|
||||||
else
|
else
|
||||||
@@ -290,7 +290,7 @@ namespace transport
|
|||||||
auto address = r->GetNTCPAddress (!context.SupportsV6 ());
|
auto address = r->GetNTCPAddress (!context.SupportsV6 ());
|
||||||
if (address && !r->UsesIntroducer () && !r->IsUnreachable () && msg->GetLength () < NTCP_MAX_MESSAGE_SIZE)
|
if (address && !r->UsesIntroducer () && !r->IsUnreachable () && msg->GetLength () < NTCP_MAX_MESSAGE_SIZE)
|
||||||
{
|
{
|
||||||
auto s = new NTCPClient (m_Service, address->host, address->port, *r);
|
auto s = new NTCPClient (m_Service, address->host, address->port, r);
|
||||||
AddNTCPSession (s);
|
AddNTCPSession (s);
|
||||||
s->SendI2NPMessage (msg);
|
s->SendI2NPMessage (msg);
|
||||||
}
|
}
|
||||||
@@ -323,7 +323,7 @@ namespace transport
|
|||||||
void Transports::HandleResendTimer (const boost::system::error_code& ecode,
|
void Transports::HandleResendTimer (const boost::system::error_code& ecode,
|
||||||
boost::asio::deadline_timer * timer, const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg)
|
boost::asio::deadline_timer * timer, const i2p::data::IdentHash& ident, i2p::I2NPMessage * msg)
|
||||||
{
|
{
|
||||||
RouterInfo * r = netdb.FindRouter (ident);
|
auto r = netdb.FindRouter (ident);
|
||||||
if (r)
|
if (r)
|
||||||
{
|
{
|
||||||
LogPrint ("Router found. Sending message");
|
LogPrint ("Router found. Sending message");
|
||||||
@@ -360,7 +360,7 @@ namespace transport
|
|||||||
{
|
{
|
||||||
auto router = i2p::data::netdb.GetRandomRouter ();
|
auto router = i2p::data::netdb.GetRandomRouter ();
|
||||||
if (router && router->IsSSU () && m_SSUServer)
|
if (router && router->IsSSU () && m_SSUServer)
|
||||||
m_SSUServer->GetSession (router.get (), true); // peer test
|
m_SSUServer->GetSession (router, true); // peer test
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
12
Tunnel.cpp
12
Tunnel.cpp
@@ -466,9 +466,9 @@ namespace tunnel
|
|||||||
if (!inboundTunnel) return;
|
if (!inboundTunnel) return;
|
||||||
LogPrint ("Creating one hop outbound tunnel...");
|
LogPrint ("Creating one hop outbound tunnel...");
|
||||||
CreateTunnel<OutboundTunnel> (
|
CreateTunnel<OutboundTunnel> (
|
||||||
new TunnelConfig (std::vector<const i2p::data::RouterInfo *>
|
new TunnelConfig (std::vector<std::shared_ptr<const i2p::data::RouterInfo> >
|
||||||
{
|
{
|
||||||
i2p::data::netdb.GetRandomRouter ().get ()
|
i2p::data::netdb.GetRandomRouter ()
|
||||||
},
|
},
|
||||||
inboundTunnel->GetTunnelConfig ()));
|
inboundTunnel->GetTunnelConfig ()));
|
||||||
}
|
}
|
||||||
@@ -519,9 +519,9 @@ namespace tunnel
|
|||||||
// trying to create one more inbound tunnel
|
// trying to create one more inbound tunnel
|
||||||
LogPrint ("Creating one hop inbound tunnel...");
|
LogPrint ("Creating one hop inbound tunnel...");
|
||||||
CreateTunnel<InboundTunnel> (
|
CreateTunnel<InboundTunnel> (
|
||||||
new TunnelConfig (std::vector<const i2p::data::RouterInfo *>
|
new TunnelConfig (std::vector<std::shared_ptr<const i2p::data::RouterInfo> >
|
||||||
{
|
{
|
||||||
i2p::data::netdb.GetRandomRouter ().get ()
|
i2p::data::netdb.GetRandomRouter ()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -609,9 +609,9 @@ namespace tunnel
|
|||||||
void Tunnels::CreateZeroHopsInboundTunnel ()
|
void Tunnels::CreateZeroHopsInboundTunnel ()
|
||||||
{
|
{
|
||||||
CreateTunnel<InboundTunnel> (
|
CreateTunnel<InboundTunnel> (
|
||||||
new TunnelConfig (std::vector<const i2p::data::RouterInfo *>
|
new TunnelConfig (std::vector<std::shared_ptr<const i2p::data::RouterInfo> >
|
||||||
{
|
{
|
||||||
&i2p::context.GetRouterInfo ()
|
i2p::context.GetSharedRouterInfo ()
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
2
Tunnel.h
2
Tunnel.h
@@ -79,7 +79,7 @@ namespace tunnel
|
|||||||
|
|
||||||
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
|
void SendTunnelDataMsg (const uint8_t * gwHash, uint32_t gwTunnel, i2p::I2NPMessage * msg);
|
||||||
void SendTunnelDataMsg (const std::vector<TunnelMessageBlock>& msgs); // multiple messages
|
void SendTunnelDataMsg (const std::vector<TunnelMessageBlock>& msgs); // multiple messages
|
||||||
const i2p::data::RouterInfo * GetEndpointRouter () const
|
std::shared_ptr<const i2p::data::RouterInfo> GetEndpointRouter () const
|
||||||
{ return GetTunnelConfig ()->GetLastHop ()->router; };
|
{ return GetTunnelConfig ()->GetLastHop ()->router; };
|
||||||
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
|
size_t GetNumSentBytes () const { return m_Gateway.GetNumSentBytes (); };
|
||||||
|
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
#include <memory>
|
||||||
#include "aes.h"
|
#include "aes.h"
|
||||||
#include "RouterInfo.h"
|
#include "RouterInfo.h"
|
||||||
#include "RouterContext.h"
|
#include "RouterContext.h"
|
||||||
@@ -14,7 +15,7 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
struct TunnelHopConfig
|
struct TunnelHopConfig
|
||||||
{
|
{
|
||||||
const i2p::data::RouterInfo * router, * nextRouter;
|
std::shared_ptr<const i2p::data::RouterInfo> router, nextRouter;
|
||||||
uint32_t tunnelID, nextTunnelID;
|
uint32_t tunnelID, nextTunnelID;
|
||||||
uint8_t layerKey[32];
|
uint8_t layerKey[32];
|
||||||
uint8_t ivKey[32];
|
uint8_t ivKey[32];
|
||||||
@@ -26,7 +27,7 @@ namespace tunnel
|
|||||||
i2p::crypto::TunnelDecryption decryption;
|
i2p::crypto::TunnelDecryption decryption;
|
||||||
int recordIndex; // record # in tunnel build message
|
int recordIndex; // record # in tunnel build message
|
||||||
|
|
||||||
TunnelHopConfig (const i2p::data::RouterInfo * r)
|
TunnelHopConfig (std::shared_ptr<const i2p::data::RouterInfo> r)
|
||||||
{
|
{
|
||||||
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
CryptoPP::RandomNumberGenerator& rnd = i2p::context.GetRandomNumberGenerator ();
|
||||||
rnd.GenerateBlock (layerKey, 32);
|
rnd.GenerateBlock (layerKey, 32);
|
||||||
@@ -36,14 +37,14 @@ namespace tunnel
|
|||||||
isGateway = true;
|
isGateway = true;
|
||||||
isEndpoint = true;
|
isEndpoint = true;
|
||||||
router = r;
|
router = r;
|
||||||
nextRouter = 0;
|
//nextRouter = nullptr;
|
||||||
nextTunnelID = 0;
|
nextTunnelID = 0;
|
||||||
|
|
||||||
next = 0;
|
next = nullptr;
|
||||||
prev = 0;
|
prev = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetNextRouter (const i2p::data::RouterInfo * r)
|
void SetNextRouter (std::shared_ptr<const i2p::data::RouterInfo> r)
|
||||||
{
|
{
|
||||||
nextRouter = r;
|
nextRouter = r;
|
||||||
isEndpoint = false;
|
isEndpoint = false;
|
||||||
@@ -88,7 +89,7 @@ namespace tunnel
|
|||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
||||||
TunnelConfig (std::vector<const i2p::data::RouterInfo *> peers,
|
TunnelConfig (std::vector<std::shared_ptr<const i2p::data::RouterInfo> > peers,
|
||||||
const TunnelConfig * replyTunnelConfig = nullptr) // replyTunnelConfig=nullptr means inbound
|
const TunnelConfig * replyTunnelConfig = nullptr) // replyTunnelConfig=nullptr means inbound
|
||||||
{
|
{
|
||||||
TunnelHopConfig * prev = nullptr;
|
TunnelHopConfig * prev = nullptr;
|
||||||
@@ -109,7 +110,7 @@ namespace tunnel
|
|||||||
m_LastHop->SetReplyHop (replyTunnelConfig->GetFirstHop ());
|
m_LastHop->SetReplyHop (replyTunnelConfig->GetFirstHop ());
|
||||||
}
|
}
|
||||||
else // inbound
|
else // inbound
|
||||||
m_LastHop->SetNextRouter (&i2p::context.GetRouterInfo ());
|
m_LastHop->SetNextRouter (i2p::context.GetSharedRouterInfo ());
|
||||||
}
|
}
|
||||||
|
|
||||||
~TunnelConfig ()
|
~TunnelConfig ()
|
||||||
@@ -184,7 +185,7 @@ namespace tunnel
|
|||||||
if (hop->isGateway) // inbound tunnel
|
if (hop->isGateway) // inbound tunnel
|
||||||
newHop->SetReplyHop (m_FirstHop); // use it as reply tunnel
|
newHop->SetReplyHop (m_FirstHop); // use it as reply tunnel
|
||||||
else
|
else
|
||||||
newHop->SetNextRouter (&i2p::context.GetRouterInfo ());
|
newHop->SetNextRouter (i2p::context.GetSharedRouterInfo ());
|
||||||
}
|
}
|
||||||
if (!hop->next) newConfig->m_FirstHop = newHop; // last hop
|
if (!hop->next) newConfig->m_FirstHop = newHop; // last hop
|
||||||
|
|
||||||
@@ -195,7 +196,7 @@ namespace tunnel
|
|||||||
|
|
||||||
TunnelConfig * Clone (const TunnelConfig * replyTunnelConfig = nullptr) const
|
TunnelConfig * Clone (const TunnelConfig * replyTunnelConfig = nullptr) const
|
||||||
{
|
{
|
||||||
std::vector<const i2p::data::RouterInfo *> peers;
|
std::vector<std::shared_ptr<const i2p::data::RouterInfo> > peers;
|
||||||
TunnelHopConfig * hop = m_FirstHop;
|
TunnelHopConfig * hop = m_FirstHop;
|
||||||
while (hop)
|
while (hop)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -235,12 +235,12 @@ namespace tunnel
|
|||||||
m_LocalDestination.ProcessDeliveryStatusMessage (msg);
|
m_LocalDestination.ProcessDeliveryStatusMessage (msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
const i2p::data::RouterInfo * TunnelPool::SelectNextHop (const i2p::data::RouterInfo * prevHop) const
|
std::shared_ptr<const i2p::data::RouterInfo> TunnelPool::SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const
|
||||||
{
|
{
|
||||||
auto hop = m_NumHops >= 3 ? i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop).get () :
|
auto hop = m_NumHops >= 3 ? i2p::data::netdb.GetHighBandwidthRandomRouter (prevHop) :
|
||||||
i2p::data::netdb.GetRandomRouter (prevHop).get ();
|
i2p::data::netdb.GetRandomRouter (prevHop);
|
||||||
if (!hop)
|
if (!hop)
|
||||||
hop = i2p::data::netdb.GetRandomRouter ().get ();
|
hop = i2p::data::netdb.GetRandomRouter ();
|
||||||
return hop;
|
return hop;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -250,8 +250,8 @@ namespace tunnel
|
|||||||
if (!outboundTunnel)
|
if (!outboundTunnel)
|
||||||
outboundTunnel = tunnels.GetNextOutboundTunnel ();
|
outboundTunnel = tunnels.GetNextOutboundTunnel ();
|
||||||
LogPrint ("Creating destination inbound tunnel...");
|
LogPrint ("Creating destination inbound tunnel...");
|
||||||
const i2p::data::RouterInfo * prevHop = &i2p::context.GetRouterInfo ();
|
auto prevHop = i2p::context.GetSharedRouterInfo ();
|
||||||
std::vector<const i2p::data::RouterInfo *> hops;
|
std::vector<std::shared_ptr<const i2p::data::RouterInfo> > hops;
|
||||||
int numHops = m_NumHops;
|
int numHops = m_NumHops;
|
||||||
if (outboundTunnel)
|
if (outboundTunnel)
|
||||||
{
|
{
|
||||||
@@ -294,8 +294,8 @@ namespace tunnel
|
|||||||
{
|
{
|
||||||
LogPrint ("Creating destination outbound tunnel...");
|
LogPrint ("Creating destination outbound tunnel...");
|
||||||
|
|
||||||
const i2p::data::RouterInfo * prevHop = &i2p::context.GetRouterInfo ();
|
auto prevHop = i2p::context.GetSharedRouterInfo ();
|
||||||
std::vector<const i2p::data::RouterInfo *> hops;
|
std::vector<std::shared_ptr<const i2p::data::RouterInfo> > hops;
|
||||||
for (int i = 0; i < m_NumHops; i++)
|
for (int i = 0; i < m_NumHops; i++)
|
||||||
{
|
{
|
||||||
auto hop = SelectNextHop (prevHop);
|
auto hop = SelectNextHop (prevHop);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace tunnel
|
|||||||
template<class TTunnels>
|
template<class TTunnels>
|
||||||
typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels,
|
typename TTunnels::value_type GetNextTunnel (TTunnels& tunnels,
|
||||||
typename TTunnels::value_type suggested = nullptr) const;
|
typename TTunnels::value_type suggested = nullptr) const;
|
||||||
const i2p::data::RouterInfo * SelectNextHop (const i2p::data::RouterInfo * prevHop) const;
|
std::shared_ptr<const i2p::data::RouterInfo> SelectNextHop (std::shared_ptr<const i2p::data::RouterInfo> prevHop) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
# NSIS Installer script. (Tested with NSIS 2.64 on Windows 7)
|
# NSIS Installer script. (Tested with NSIS 2.64 on Windows 7)
|
||||||
# Author: Mikal Villa (Meeh)
|
# Author: Mikal Villa (Meeh)
|
||||||
# Version: 1.0
|
# Version: 1.1
|
||||||
Name PurpleI2P
|
Name PurpleI2P
|
||||||
|
|
||||||
RequestExecutionLevel highest
|
RequestExecutionLevel highest
|
||||||
@@ -9,7 +9,7 @@ ShowInstDetails show
|
|||||||
|
|
||||||
# General Symbol Definitions
|
# General Symbol Definitions
|
||||||
!define REGKEY "SOFTWARE\$(^Name)"
|
!define REGKEY "SOFTWARE\$(^Name)"
|
||||||
!define VERSION 0.2.0.0
|
!define VERSION 0.3.0.0
|
||||||
!define COMPANY "The Privacy Solutions Project"
|
!define COMPANY "The Privacy Solutions Project"
|
||||||
!define URL "https://i2p.io"
|
!define URL "https://i2p.io"
|
||||||
|
|
||||||
@@ -64,13 +64,13 @@ Var StartMenuGroup
|
|||||||
!insertmacro MUI_LANGUAGE English
|
!insertmacro MUI_LANGUAGE English
|
||||||
|
|
||||||
# Installer attributes
|
# Installer attributes
|
||||||
OutFile PurpleI2P-0.2.0.0-win32-setup.exe
|
OutFile PurpleI2P-0.3.0.0-win32-setup.exe
|
||||||
InstallDir $PROGRAMFILES\PurpleI2P
|
InstallDir $PROGRAMFILES\PurpleI2P
|
||||||
CRCCheck on
|
CRCCheck on
|
||||||
XPStyle on
|
XPStyle on
|
||||||
BrandingText " "
|
BrandingText " "
|
||||||
ShowInstDetails show
|
ShowInstDetails show
|
||||||
VIProductVersion 0.2.0.0
|
VIProductVersion 0.3.0.0
|
||||||
VIAddVersionKey ProductName PurpleI2P
|
VIAddVersionKey ProductName PurpleI2P
|
||||||
VIAddVersionKey ProductVersion "${VERSION}"
|
VIAddVersionKey ProductVersion "${VERSION}"
|
||||||
VIAddVersionKey CompanyName "${COMPANY}"
|
VIAddVersionKey CompanyName "${COMPANY}"
|
||||||
|
|||||||
Reference in New Issue
Block a user