|
|
@ -3,6 +3,8 @@ |
|
|
|
#include "I2PEndian.h" |
|
|
|
#include "I2PEndian.h" |
|
|
|
#include <fstream> |
|
|
|
#include <fstream> |
|
|
|
#include <boost/lexical_cast.hpp> |
|
|
|
#include <boost/lexical_cast.hpp> |
|
|
|
|
|
|
|
#include <boost/atomic.hpp> |
|
|
|
|
|
|
|
#include <boost/make_shared.hpp> |
|
|
|
#include "version.h" |
|
|
|
#include "version.h" |
|
|
|
#include "Crypto.h" |
|
|
|
#include "Crypto.h" |
|
|
|
#include "Base.h" |
|
|
|
#include "Base.h" |
|
|
@ -17,14 +19,14 @@ namespace data |
|
|
|
{ |
|
|
|
{ |
|
|
|
RouterInfo::RouterInfo (): m_Buffer (nullptr) |
|
|
|
RouterInfo::RouterInfo (): m_Buffer (nullptr) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_Addresses = std::make_shared<Addresses>(); // create empty list
|
|
|
|
m_Addresses = boost::make_shared<Addresses>(); // create empty list
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
RouterInfo::RouterInfo (const std::string& fullPath): |
|
|
|
RouterInfo::RouterInfo (const std::string& fullPath): |
|
|
|
m_FullPath (fullPath), m_IsUpdated (false), m_IsUnreachable (false), |
|
|
|
m_FullPath (fullPath), m_IsUpdated (false), m_IsUnreachable (false), |
|
|
|
m_SupportedTransports (0), m_Caps (0) |
|
|
|
m_SupportedTransports (0), m_Caps (0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_Addresses = std::make_shared<Addresses>(); // create empty list
|
|
|
|
m_Addresses = boost::make_shared<Addresses>(); // create empty list
|
|
|
|
m_Buffer = new uint8_t[MAX_RI_BUFFER_SIZE]; |
|
|
|
m_Buffer = new uint8_t[MAX_RI_BUFFER_SIZE]; |
|
|
|
ReadFromFile (); |
|
|
|
ReadFromFile (); |
|
|
|
} |
|
|
|
} |
|
|
@ -32,7 +34,7 @@ namespace data |
|
|
|
RouterInfo::RouterInfo (const uint8_t * buf, int len): |
|
|
|
RouterInfo::RouterInfo (const uint8_t * buf, int len): |
|
|
|
m_IsUpdated (true), m_IsUnreachable (false), m_SupportedTransports (0), m_Caps (0) |
|
|
|
m_IsUpdated (true), m_IsUnreachable (false), m_SupportedTransports (0), m_Caps (0) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_Addresses = std::make_shared<Addresses>(); // create empty list
|
|
|
|
m_Addresses = boost::make_shared<Addresses>(); // create empty list
|
|
|
|
m_Buffer = new uint8_t[MAX_RI_BUFFER_SIZE]; |
|
|
|
m_Buffer = new uint8_t[MAX_RI_BUFFER_SIZE]; |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
memcpy (m_Buffer, buf, len); |
|
|
|
m_BufferLen = len; |
|
|
|
m_BufferLen = len; |
|
|
@ -154,7 +156,7 @@ namespace data |
|
|
|
s.read ((char *)&m_Timestamp, sizeof (m_Timestamp)); |
|
|
|
s.read ((char *)&m_Timestamp, sizeof (m_Timestamp)); |
|
|
|
m_Timestamp = be64toh (m_Timestamp); |
|
|
|
m_Timestamp = be64toh (m_Timestamp); |
|
|
|
// read addresses
|
|
|
|
// read addresses
|
|
|
|
auto addresses = std::make_shared<Addresses>(); |
|
|
|
auto addresses = boost::make_shared<Addresses>(); |
|
|
|
uint8_t numAddresses; |
|
|
|
uint8_t numAddresses; |
|
|
|
s.read ((char *)&numAddresses, sizeof (numAddresses)); if (!s) return; |
|
|
|
s.read ((char *)&numAddresses, sizeof (numAddresses)); if (!s) return; |
|
|
|
bool introducers = false; |
|
|
|
bool introducers = false; |
|
|
@ -255,7 +257,7 @@ namespace data |
|
|
|
m_SupportedTransports |= supportedTransports; |
|
|
|
m_SupportedTransports |= supportedTransports; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
m_Addresses = addresses; |
|
|
|
boost::atomic_store (&m_Addresses, addresses); |
|
|
|
// read peers
|
|
|
|
// read peers
|
|
|
|
uint8_t numPeers; |
|
|
|
uint8_t numPeers; |
|
|
|
s.read ((char *)&numPeers, sizeof (numPeers)); if (!s) return; |
|
|
|
s.read ((char *)&numPeers, sizeof (numPeers)); if (!s) return; |
|
|
|