mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-03-10 11:28:27 +01:00
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
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:
parent
b500374f74
commit
4d9b5e685d
2 changed files with 30 additions and 19 deletions
|
@ -443,17 +443,18 @@ namespace client
|
|||
auto addr = std::make_shared<const Address>(address.substr (0, pos));
|
||||
return addr->IsValid () ? addr : nullptr;
|
||||
}
|
||||
else
|
||||
else
|
||||
#if __cplusplus >= 202002L // C++20
|
||||
if (address.ends_with (".i2p"))
|
||||
#else
|
||||
if (address.find (".i2p") != std::string::npos)
|
||||
#endif
|
||||
{
|
||||
pos = address.find (".i2p");
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
if (!m_IsEnabled) return nullptr;
|
||||
auto addr = FindAddress (address);
|
||||
if (!addr)
|
||||
LookupAddress (address); // TODO:
|
||||
return addr;
|
||||
}
|
||||
if (!m_IsEnabled) return nullptr;
|
||||
auto addr = FindAddress (address);
|
||||
if (!addr)
|
||||
LookupAddress (address); // TODO:
|
||||
return addr;
|
||||
}
|
||||
// if not .b32 we assume full base64 address
|
||||
i2p::data::IdentityEx dest;
|
||||
|
@ -566,29 +567,35 @@ namespace client
|
|||
|
||||
if (pos != std::string::npos)
|
||||
{
|
||||
std::string name = s.substr(0, pos++);
|
||||
std::string addr = s.substr(pos);
|
||||
std::string_view name = std::string_view(s).substr(0, pos++);
|
||||
std::string_view addr = std::string_view(s).substr(pos);
|
||||
|
||||
size_t pos = addr.find('#');
|
||||
if (pos != std::string::npos)
|
||||
if (pos != addr.npos)
|
||||
addr = addr.substr(0, pos); // remove comments
|
||||
|
||||
pos = name.find(".b32.i2p");
|
||||
if (pos != std::string::npos)
|
||||
#if __cplusplus >= 202002L // C++20
|
||||
if (name.ends_with (".b32.i2p"))
|
||||
#else
|
||||
if (name.find(".b32.i2p") != name.npos)
|
||||
#endif
|
||||
{
|
||||
LogPrint (eLogError, "Addressbook: Skipped adding of b32 address: ", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
pos = name.find(".i2p");
|
||||
if (pos == std::string::npos)
|
||||
#if __cplusplus >= 202002L // C++20
|
||||
if (name.ends_with (".i2p"))
|
||||
#else
|
||||
if (name.find(".i2p") == name.npos)
|
||||
#endif
|
||||
{
|
||||
LogPrint (eLogError, "Addressbook: Malformed domain: ", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
auto ident = std::make_shared<i2p::data::IdentityEx> ();
|
||||
if (!ident->FromBase64(addr)) {
|
||||
if (!ident->FromBase64(addr))
|
||||
{
|
||||
LogPrint (eLogError, "Addressbook: Malformed address ", addr, " for ", name);
|
||||
incomplete = f.eof ();
|
||||
continue;
|
||||
|
|
|
@ -547,7 +547,11 @@ namespace client
|
|||
{
|
||||
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"
|
||||
#endif
|
||||
LogPrint(eLogDebug, "Clients: Tunnels extra config file: ", it);
|
||||
ReadTunnels (it, numClientTunnels, numServerTunnels);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue