replace boost::lexical_cast by std::from_chars and std::to_string
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 / 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 / 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/386 (push) Waiting to run
Build containers / Building container for linux/amd64 (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 / Pushing merged manifest (push) Blocked by required conditions

This commit is contained in:
orignal 2025-02-21 20:34:53 -05:00
parent 7e3d9649de
commit 81dae1997d

View file

@ -12,7 +12,6 @@
#include <fstream> #include <fstream>
#include <memory> #include <memory>
#include <charconv> #include <charconv>
#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp> // for boost::to_lower #include <boost/algorithm/string.hpp> // for boost::to_lower
#ifndef __cpp_lib_atomic_shared_ptr #ifndef __cpp_lib_atomic_shared_ptr
#include <boost/atomic.hpp> #include <boost/atomic.hpp>
@ -263,27 +262,17 @@ namespace data
} }
else if (key == "port") else if (key == "port")
{ {
try auto res = std::from_chars(value.data(), value.data() + value.size(), address->port);
{ if (res.ec != std::errc())
address->port = boost::lexical_cast<int>(value); LogPrint (eLogWarning, "RouterInfo: 'port' conversion error: ", std::make_error_code (res.ec).message ());
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'port' exception ", ex.what ());
}
} }
else if (key == "mtu") else if (key == "mtu")
{ {
if (address->ssu) if (address->ssu)
{ {
try auto res = std::from_chars(value.data(), value.data() + value.size(), address->ssu->mtu);
{ if (res.ec != std::errc())
address->ssu->mtu = boost::lexical_cast<int>(value); LogPrint (eLogWarning, "RouterInfo: 'mtu' conversion error: ", std::make_error_code (res.ec).message ());
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'mtu' exception ", ex.what ());
}
} }
else else
LogPrint (eLogWarning, "RouterInfo: Unexpected field 'mtu' for NTCP2"); LogPrint (eLogWarning, "RouterInfo: Unexpected field 'mtu' for NTCP2");
@ -349,27 +338,17 @@ namespace data
auto key1 = key.substr(0, key.length () - 1); auto key1 = key.substr(0, key.length () - 1);
if (key1 == "itag") if (key1 == "itag")
{ {
try auto res = std::from_chars(value.data(), value.data() + value.size(), introducer.iTag);
{ if (res.ec != std::errc())
introducer.iTag = boost::lexical_cast<uint32_t>(value); LogPrint (eLogWarning, "RouterInfo: 'itag' conversion error: ", std::make_error_code (res.ec).message ());
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'itag' exception ", ex.what ());
}
} }
else if (key1 == "ih") else if (key1 == "ih")
Base64ToByteStream (value.data (), value.length (), introducer.iH, 32); Base64ToByteStream (value.data (), value.length (), introducer.iH, 32);
else if (key1 == "iexp") else if (key1 == "iexp")
{ {
try auto res = std::from_chars(value.data(), value.data() + value.size(), introducer.iExp);
{ if (res.ec != std::errc())
introducer.iExp = boost::lexical_cast<uint32_t>(value); LogPrint (eLogWarning, "RouterInfo: 'iexp' conversion error: ", std::make_error_code (res.ec).message ());
}
catch (std::exception& ex)
{
LogPrint (eLogWarning, "RouterInfo: 'iexp' exception ", ex.what ());
}
} }
} }
} }
@ -1402,9 +1381,9 @@ namespace data
if (!introducer.iTag) continue; if (!introducer.iTag) continue;
if (introducer.iExp) // expiration is specified if (introducer.iExp) // expiration is specified
{ {
WriteString ("iexp" + boost::lexical_cast<std::string>(i), properties); WriteString ("iexp" + std::to_string(i), properties);
properties << '='; properties << '=';
WriteString (boost::lexical_cast<std::string>(introducer.iExp), properties); WriteString (std::to_string(introducer.iExp), properties);
properties << ';'; properties << ';';
} }
i++; i++;
@ -1413,7 +1392,7 @@ namespace data
for (const auto& introducer: address.ssu->introducers) for (const auto& introducer: address.ssu->introducers)
{ {
if (!introducer.iTag) continue; if (!introducer.iTag) continue;
WriteString ("ih" + boost::lexical_cast<std::string>(i), properties); WriteString ("ih" + std::to_string(i), properties);
properties << '='; properties << '=';
char value[64]; char value[64];
size_t l = ByteStreamToBase64 (introducer.iH, 32, value, 64); size_t l = ByteStreamToBase64 (introducer.iH, 32, value, 64);
@ -1426,9 +1405,9 @@ namespace data
for (const auto& introducer: address.ssu->introducers) for (const auto& introducer: address.ssu->introducers)
{ {
if (!introducer.iTag) continue; if (!introducer.iTag) continue;
WriteString ("itag" + boost::lexical_cast<std::string>(i), properties); WriteString ("itag" + std::to_string(i), properties);
properties << '='; properties << '=';
WriteString (boost::lexical_cast<std::string>(introducer.iTag), properties); WriteString (std::to_string(introducer.iTag), properties);
properties << ';'; properties << ';';
i++; i++;
} }
@ -1442,7 +1421,7 @@ namespace data
{ {
WriteString ("mtu", properties); WriteString ("mtu", properties);
properties << '='; properties << '=';
WriteString (boost::lexical_cast<std::string>(address.ssu->mtu), properties); WriteString (std::to_string(address.ssu->mtu), properties);
properties << ';'; properties << ';';
} }
} }
@ -1450,7 +1429,7 @@ namespace data
{ {
WriteString ("port", properties); WriteString ("port", properties);
properties << '='; properties << '=';
WriteString (boost::lexical_cast<std::string>(address.port), properties); WriteString (std::to_string(address.port), properties);
properties << ';'; properties << ';';
} }
if (address.IsNTCP2 () || address.IsSSU2 ()) if (address.IsNTCP2 () || address.IsSSU2 ())