use ends_with to recognize .i2p addresses
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 / CMake with -DWITH_UPNP=ON (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 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 / Building container for linux/386 (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions

This commit is contained in:
orignal 2025-03-08 16:03:36 -05:00
parent b500374f74
commit 4d9b5e685d
2 changed files with 30 additions and 19 deletions

View file

@ -444,9 +444,11 @@ namespace client
return addr->IsValid () ? addr : nullptr; return addr->IsValid () ? addr : nullptr;
} }
else else
{ #if __cplusplus >= 202002L // C++20
pos = address.find (".i2p"); if (address.ends_with (".i2p"))
if (pos != std::string::npos) #else
if (address.find (".i2p") != std::string::npos)
#endif
{ {
if (!m_IsEnabled) return nullptr; if (!m_IsEnabled) return nullptr;
auto addr = FindAddress (address); auto addr = FindAddress (address);
@ -454,7 +456,6 @@ namespace client
LookupAddress (address); // TODO: LookupAddress (address); // TODO:
return addr; return addr;
} }
}
// if not .b32 we assume full base64 address // if not .b32 we assume full base64 address
i2p::data::IdentityEx dest; i2p::data::IdentityEx dest;
if (!dest.FromBase64 (address)) if (!dest.FromBase64 (address))
@ -566,29 +567,35 @@ namespace client
if (pos != std::string::npos) if (pos != std::string::npos)
{ {
std::string name = s.substr(0, pos++); std::string_view name = std::string_view(s).substr(0, pos++);
std::string addr = s.substr(pos); std::string_view addr = std::string_view(s).substr(pos);
size_t pos = addr.find('#'); size_t pos = addr.find('#');
if (pos != std::string::npos) if (pos != addr.npos)
addr = addr.substr(0, pos); // remove comments addr = addr.substr(0, pos); // remove comments
#if __cplusplus >= 202002L // C++20
pos = name.find(".b32.i2p"); if (name.ends_with (".b32.i2p"))
if (pos != std::string::npos) #else
if (name.find(".b32.i2p") != name.npos)
#endif
{ {
LogPrint (eLogError, "Addressbook: Skipped adding of b32 address: ", name); LogPrint (eLogError, "Addressbook: Skipped adding of b32 address: ", name);
continue; continue;
} }
pos = name.find(".i2p"); #if __cplusplus >= 202002L // C++20
if (pos == std::string::npos) if (name.ends_with (".i2p"))
#else
if (name.find(".i2p") == name.npos)
#endif
{ {
LogPrint (eLogError, "Addressbook: Malformed domain: ", name); LogPrint (eLogError, "Addressbook: Malformed domain: ", name);
continue; continue;
} }
auto ident = std::make_shared<i2p::data::IdentityEx> (); auto ident = std::make_shared<i2p::data::IdentityEx> ();
if (!ident->FromBase64(addr)) { if (!ident->FromBase64(addr))
{
LogPrint (eLogError, "Addressbook: Malformed address ", addr, " for ", name); LogPrint (eLogError, "Addressbook: Malformed address ", addr, " for ", name);
incomplete = f.eof (); incomplete = f.eof ();
continue; continue;

View file

@ -547,7 +547,11 @@ namespace client
{ {
for (auto& it: files) for (auto& it: files)
{ {
#if __cplusplus >= 202002L // C++20
if (!it.ends_with (".conf")) continue;
#else
if (it.substr(it.size() - 5) != ".conf") continue; // skip files which not ends with ".conf" if (it.substr(it.size() - 5) != ".conf") continue; // skip files which not ends with ".conf"
#endif
LogPrint(eLogDebug, "Clients: Tunnels extra config file: ", it); LogPrint(eLogDebug, "Clients: Tunnels extra config file: ", it);
ReadTunnels (it, numClientTunnels, numServerTunnels); ReadTunnels (it, numClientTunnels, numServerTunnels);
} }