From 9c8e4489887d0cf1edbfd1ea418220731348faf9 Mon Sep 17 00:00:00 2001 From: orignal Date: Tue, 25 Aug 2026 08:51:05 -0400 Subject: [PATCH] lowercase failure reason. check some invlalid file names on windows only --- libi2pd_client/Torrents.cpp | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index 993d5813..7ed74b82 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -16,7 +16,6 @@ #include #include #include -#include "version.h" #include "Log.h" #include "I2PEndian.h" #include "ClientContext.h" @@ -412,16 +411,19 @@ namespace torrents if (ch == '/' || ch == '\\' || ch == ':' || ch == '<' || ch == '>' || ch == '"' || ch == '|' || ch == '?' || ch == '*' || (unsigned char)ch < 0x20) return false; - using namespace std::string_view_literals; +#ifdef _WIN32 static constexpr std::array reserved { - "CON"sv, "PRN"sv, "AUX"sv, "NUL"sv, - "COM1"sv, "COM2"sv, "COM3"sv, "COM4"sv, "COM5"sv, "COM6"sv, "COM7"sv, "COM8"sv, "COM9"sv, - "LPT1"sv, "LPT2"sv, "LPT3"sv, "LPT4"sv, "LPT5"sv, "LPT6"sv, "LPT7"sv, "LPT8"sv, "LPT9"sv + "CON", "PRN", "AUX", "NUL", "COM1", "COM2", "COM3", "COM4", "COM5", + "COM6", "COM7", "COM8", "COM9", "LPT1", "LPT2", "LPT3", "LPT4", + "LPT5", "LPT6", "LPT7", "LPT8", "LPT9" }; std::string stem (name.substr (0, name.find ('.'))); boost::to_upper (stem); return std::find (reserved.begin (), reserved.end (), stem) == reserved.end (); +#else + return true; +#endif } size_t Torrent::ParseFiles (std::string_view buf) @@ -505,7 +507,7 @@ namespace torrents } else if (key == "peers") return ParsePeers (trackerID, buf); - else if (key == "Failure Reason") + else if (key == "failure reason") { auto [reason, l] = ExtractByteString (buf); LogPrint (eLogError, "Torrents: Tracker error: ", reason); @@ -1529,7 +1531,7 @@ namespace torrents void PeerConnection::SendExtendedMsg () { - std::string payload = CreateDictionary ({{ CreateByteString ("v"), CreateByteString ("i2pd " + std::string (VERSION)) }}); + std::string payload = CreateDictionary ({{ CreateByteString ("v"), CreateByteString ("i2pd") }}); std::vector sendBuffer (payload.length () + 1 + 5); htobe32buf (sendBuffer.data (), payload.length () + 1 + 1); // length sendBuffer[4] = eMessageTypeExtended; // msg ID