mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 19:57:48 +02:00
fix code syle(spaces->tabs, tabulations)
Signed-off-by: R4SAS <r4sas@i2pmail.org>
This commit is contained in:
parent
78640532e1
commit
44f6683c41
115 changed files with 3206 additions and 3161 deletions
|
@ -35,12 +35,12 @@ namespace data
|
|||
}
|
||||
|
||||
RouterInfo::RouterInfo (const uint8_t * buf, int len):
|
||||
m_IsUpdated (true), m_IsUnreachable (false), m_SupportedTransports (0),
|
||||
m_IsUpdated (true), m_IsUnreachable (false), m_SupportedTransports (0),
|
||||
m_Caps (0), m_Version (0)
|
||||
{
|
||||
m_Addresses = boost::make_shared<Addresses>(); // create empty list
|
||||
if (len <= MAX_RI_BUFFER_SIZE)
|
||||
{
|
||||
{
|
||||
m_Buffer = new uint8_t[MAX_RI_BUFFER_SIZE];
|
||||
memcpy (m_Buffer, buf, len);
|
||||
m_BufferLen = len;
|
||||
|
@ -173,7 +173,6 @@ namespace data
|
|||
LogPrint (eLogError, "RouterInfo: malformed message");
|
||||
m_IsUnreachable = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void RouterInfo::ReadFromStream (std::istream& s)
|
||||
|
@ -192,7 +191,7 @@ namespace data
|
|||
s.read ((char *)&address->cost, sizeof (address->cost));
|
||||
s.read ((char *)&address->date, sizeof (address->date));
|
||||
bool isNTCP2Only = false;
|
||||
char transportStyle[6];
|
||||
char transportStyle[6];
|
||||
auto transportStyleLen = ReadString (transportStyle, 6, s) - 1;
|
||||
if (!strncmp (transportStyle, "NTCP", 4)) // NTCP or NTCP2
|
||||
{
|
||||
|
@ -231,13 +230,13 @@ namespace data
|
|||
address->host.to_string (ecode);
|
||||
if (!ecode)
|
||||
#endif
|
||||
{
|
||||
{
|
||||
// add supported protocol
|
||||
if (address->host.is_v4 ())
|
||||
supportedTransports |= (address->transportStyle == eTransportNTCP) ? eNTCPV4 : eSSUV4;
|
||||
else
|
||||
supportedTransports |= (address->transportStyle == eTransportNTCP) ? eNTCPV6 : eSSUV6;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (!strcmp (key, "port"))
|
||||
|
@ -262,15 +261,15 @@ namespace data
|
|||
{
|
||||
if (!address->ntcp2) address->ntcp2.reset (new NTCP2Ext ());
|
||||
supportedTransports |= (address->host.is_v4 ()) ? eNTCP2V4 : eNTCP2V6;
|
||||
Base64ToByteStream (value, strlen (value), address->ntcp2->staticKey, 32);
|
||||
}
|
||||
Base64ToByteStream (value, strlen (value), address->ntcp2->staticKey, 32);
|
||||
}
|
||||
else if (!strcmp (key, "i")) // ntcp2 iv
|
||||
{
|
||||
if (!address->ntcp2) address->ntcp2.reset (new NTCP2Ext ());
|
||||
supportedTransports |= (address->host.is_v4 ()) ? eNTCP2V4 : eNTCP2V6;
|
||||
Base64ToByteStream (value, strlen (value), address->ntcp2->iv, 16);
|
||||
Base64ToByteStream (value, strlen (value), address->ntcp2->iv, 16);
|
||||
address->ntcp2->isPublished = true; // presence if "i" means "published"
|
||||
}
|
||||
}
|
||||
else if (key[0] == 'i')
|
||||
{
|
||||
// introducers
|
||||
|
@ -278,7 +277,7 @@ namespace data
|
|||
{
|
||||
LogPrint (eLogError, "RouterInfo: Introducer is presented for non-SSU address. Skipped");
|
||||
continue;
|
||||
}
|
||||
}
|
||||
introducers = true;
|
||||
size_t l = strlen(key);
|
||||
unsigned char index = key[l-1] - '0'; // TODO:
|
||||
|
@ -309,7 +308,7 @@ namespace data
|
|||
}
|
||||
if (introducers) supportedTransports |= eSSUV4; // in case if host is not presented
|
||||
if (isNTCP2Only && address->ntcp2) address->ntcp2->isNTCP2Only = true;
|
||||
if (supportedTransports)
|
||||
if (supportedTransports)
|
||||
{
|
||||
addresses->push_back(address);
|
||||
m_SupportedTransports |= supportedTransports;
|
||||
|
@ -349,13 +348,13 @@ namespace data
|
|||
while (*ch)
|
||||
{
|
||||
if (*ch >= '0' && *ch <= '9')
|
||||
{
|
||||
m_Version *= 10;
|
||||
{
|
||||
m_Version *= 10;
|
||||
m_Version += (*ch - '0');
|
||||
}
|
||||
}
|
||||
ch++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// check netId
|
||||
else if (!strcmp (key, ROUTER_INFO_PROPERTY_NETID) && atoi (value) != i2p::context.GetNetID ())
|
||||
{
|
||||
|
@ -384,9 +383,10 @@ namespace data
|
|||
SetUnreachable (true);
|
||||
}
|
||||
|
||||
bool RouterInfo::IsFamily(const std::string & fam) const {
|
||||
return m_Family == fam;
|
||||
}
|
||||
bool RouterInfo::IsFamily(const std::string & fam) const
|
||||
{
|
||||
return m_Family == fam;
|
||||
}
|
||||
|
||||
void RouterInfo::ExtractCaps (const char * value)
|
||||
{
|
||||
|
@ -580,7 +580,7 @@ namespace data
|
|||
properties << '=';
|
||||
WriteString (boost::lexical_cast<std::string>(address.port), properties);
|
||||
properties << ';';
|
||||
}
|
||||
}
|
||||
if (address.IsNTCP2 ())
|
||||
{
|
||||
// publish s and v for NTCP2
|
||||
|
@ -588,7 +588,7 @@ namespace data
|
|||
WriteString (address.ntcp2->staticKey.ToBase64 (), properties); properties << ';';
|
||||
WriteString ("v", properties); properties << '=';
|
||||
WriteString ("2", properties); properties << ';';
|
||||
}
|
||||
}
|
||||
|
||||
uint16_t size = htobe16 (properties.str ().size ());
|
||||
s.write ((char *)&size, sizeof (size));
|
||||
|
@ -742,7 +742,7 @@ namespace data
|
|||
addr->ntcp2->isNTCP2Only = true; // NTCP2 only address
|
||||
if (port) addr->ntcp2->isPublished = true;
|
||||
memcpy (addr->ntcp2->staticKey, staticKey, 32);
|
||||
memcpy (addr->ntcp2->iv, iv, 16);
|
||||
memcpy (addr->ntcp2->iv, iv, 16);
|
||||
m_Addresses->push_back(std::move(addr));
|
||||
}
|
||||
|
||||
|
@ -854,7 +854,7 @@ namespace data
|
|||
m_SupportedTransports |= eNTCPV6 | eSSUV6 | eNTCP2V6;
|
||||
}
|
||||
|
||||
void RouterInfo::EnableV4 ()
|
||||
void RouterInfo::EnableV4 ()
|
||||
{
|
||||
if (!IsV4 ())
|
||||
m_SupportedTransports |= eNTCPV4 | eSSUV4 | eNTCP2V4;
|
||||
|
@ -877,7 +877,7 @@ namespace data
|
|||
}
|
||||
}
|
||||
|
||||
void RouterInfo::DisableV4 ()
|
||||
void RouterInfo::DisableV4 ()
|
||||
{
|
||||
if (IsV4 ())
|
||||
{
|
||||
|
@ -926,7 +926,7 @@ namespace data
|
|||
});
|
||||
}
|
||||
|
||||
template<typename Filter>
|
||||
template<typename Filter>
|
||||
std::shared_ptr<const RouterInfo::Address> RouterInfo::GetAddress (Filter filter) const
|
||||
{
|
||||
// TODO: make it more generic using comparator
|
||||
|
@ -937,7 +937,7 @@ namespace data
|
|||
#endif
|
||||
for (const auto& address : *addresses)
|
||||
if (filter (address)) return address;
|
||||
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue