mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-04-28 11:47:48 +02:00
always pass RouterInfo param values as string_view
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / buster (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
Build containers / Building container for linux/amd64 (push) Waiting to run
Some checks are pending
Build Debian packages / bookworm (push) Waiting to run
Build Debian packages / bullseye (push) Waiting to run
Build Debian packages / buster (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=no (push) Waiting to run
Build on OSX / With USE_UPNP=yes (push) Waiting to run
Build on Windows / x86_64 (push) Waiting to run
Build on Windows / clang-x86_64 (push) Waiting to run
Build on Windows / i686 (push) Waiting to run
Build on Windows / ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake clang-x86_64 (push) Waiting to run
Build on Windows / CMake i686 (push) Waiting to run
Build on Windows / CMake ucrt-x86_64 (push) Waiting to run
Build on Windows / CMake x86_64 (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=no (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=yes (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=OFF (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=ON (push) Waiting to run
Build containers / Building container for linux/arm64 (push) Waiting to run
Build containers / Building container for linux/arm/v7 (push) Waiting to run
Build containers / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
Build containers / Building container for linux/amd64 (push) Waiting to run
This commit is contained in:
parent
70f99ccc21
commit
d09367d686
4 changed files with 21 additions and 33 deletions
|
@ -213,6 +213,7 @@ namespace data
|
|||
uint8_t numAddresses = buf[offset]; offset++;
|
||||
for (int i = 0; i < numAddresses; i++)
|
||||
{
|
||||
if (offset + 9 > len) return false; // 1 byte cost + 8 bytes date
|
||||
uint8_t supportedTransports = 0;
|
||||
auto address = NewAddress ();
|
||||
offset++; // cost, ignore
|
||||
|
@ -231,6 +232,7 @@ namespace data
|
|||
address->transportStyle = eTransportUnknown;
|
||||
address->caps = 0;
|
||||
address->port = 0;
|
||||
if (offset + 2 > len) return false;
|
||||
uint16_t size = bufbe16toh (buf + offset); offset += 2; // size
|
||||
if (offset + size >= len) return false;
|
||||
if (address->transportStyle == eTransportUnknown)
|
||||
|
@ -434,10 +436,11 @@ namespace data
|
|||
boost::atomic_store (&m_Addresses, addresses);
|
||||
#endif
|
||||
// read peers
|
||||
if (offset + 1 > len) return false;
|
||||
uint8_t numPeers = buf[offset]; offset++; // num peers
|
||||
offset += numPeers*32; // TODO: read peers
|
||||
if (offset >= len) return false;
|
||||
// read properties
|
||||
if (offset + 2 > len) return false;
|
||||
m_Version = 0;
|
||||
bool isNetId = false;
|
||||
std::string family;
|
||||
|
@ -499,7 +502,7 @@ namespace data
|
|||
}
|
||||
else if (key == ROUTER_INFO_PROPERTY_FAMILY_SIG)
|
||||
{
|
||||
if (netdb.GetFamilies ().VerifyFamily (family, GetIdentHash (), std::string(value).c_str ())) // TODO
|
||||
if (netdb.GetFamilies ().VerifyFamily (family, GetIdentHash (), value)) // TODO
|
||||
m_FamilyID = netdb.GetFamilies ().GetFamilyID (family);
|
||||
else
|
||||
{
|
||||
|
@ -520,12 +523,11 @@ namespace data
|
|||
return m_FamilyID == famid;
|
||||
}
|
||||
|
||||
void RouterInfo::ExtractCaps (const char * value)
|
||||
void RouterInfo::ExtractCaps (std::string_view value)
|
||||
{
|
||||
const char * cap = value;
|
||||
while (*cap)
|
||||
for (auto cap: value)
|
||||
{
|
||||
switch (*cap)
|
||||
switch (cap)
|
||||
{
|
||||
case CAPS_FLAG_FLOODFILL:
|
||||
m_Caps |= Caps::eFloodfill;
|
||||
|
@ -534,16 +536,16 @@ namespace data
|
|||
case CAPS_FLAG_LOW_BANDWIDTH2:
|
||||
case CAPS_FLAG_LOW_BANDWIDTH3:
|
||||
case CAPS_FLAG_LOW_BANDWIDTH4:
|
||||
m_BandwidthCap = *cap;
|
||||
m_BandwidthCap = cap;
|
||||
break;
|
||||
case CAPS_FLAG_HIGH_BANDWIDTH:
|
||||
m_Caps |= Caps::eHighBandwidth;
|
||||
m_BandwidthCap = *cap;
|
||||
m_BandwidthCap = cap;
|
||||
break;
|
||||
case CAPS_FLAG_EXTRA_BANDWIDTH1:
|
||||
case CAPS_FLAG_EXTRA_BANDWIDTH2:
|
||||
m_Caps |= Caps::eExtraBandwidth | Caps::eHighBandwidth;
|
||||
m_BandwidthCap = *cap;
|
||||
m_BandwidthCap = cap;
|
||||
break;
|
||||
case CAPS_FLAG_HIDDEN:
|
||||
m_Caps |= Caps::eHidden;
|
||||
|
@ -565,22 +567,15 @@ namespace data
|
|||
break;
|
||||
default: ;
|
||||
}
|
||||
cap++;
|
||||
}
|
||||
}
|
||||
|
||||
void RouterInfo::ExtractCaps (std::string_view value)
|
||||
{
|
||||
ExtractCaps (std::string (value).c_str ()); // TODO
|
||||
}
|
||||
|
||||
uint8_t RouterInfo::ExtractAddressCaps (const char * value) const
|
||||
uint8_t RouterInfo::ExtractAddressCaps (std::string_view value) const
|
||||
{
|
||||
uint8_t caps = 0;
|
||||
const char * cap = value;
|
||||
while (*cap)
|
||||
for (auto cap: value)
|
||||
{
|
||||
switch (*cap)
|
||||
switch (cap)
|
||||
{
|
||||
case CAPS_FLAG_V4:
|
||||
caps |= AddressCaps::eV4;
|
||||
|
@ -596,14 +591,8 @@ namespace data
|
|||
break;
|
||||
default: ;
|
||||
}
|
||||
cap++;
|
||||
}
|
||||
return caps;
|
||||
}
|
||||
|
||||
uint8_t RouterInfo::ExtractAddressCaps (std::string_view value) const
|
||||
{
|
||||
return ExtractAddressCaps (std::string (value).c_str ()); // TODO:
|
||||
}
|
||||
|
||||
void RouterInfo::UpdateIntroducers (std::shared_ptr<Address> address, uint64_t ts)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue