From ab57514b5fadd28f9155bc32621a27c92e67bcd6 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 1 Oct 2026 22:31:28 -0400 Subject: [PATCH] return string instead string_view from RecognizeClientByPeerID --- libi2pd_client/TorrentsRPC.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libi2pd_client/TorrentsRPC.cpp b/libi2pd_client/TorrentsRPC.cpp index 2b1b0552..d731eebc 100644 --- a/libi2pd_client/TorrentsRPC.cpp +++ b/libi2pd_client/TorrentsRPC.cpp @@ -56,7 +56,7 @@ namespace torrents boost::json::array GetTrackerStats (std::shared_ptr torrent) const; boost::json::array GetFiles (std::shared_ptr torrent) const; static boost::json::array GetFileStats (std::shared_ptr torrent); - static std::string_view RecognizeClientByPeerID (const PeerConnection::PeerID& peerID); + static std::string RecognizeClientByPeerID (const PeerConnection::PeerID& peerID); std::string HandleTorrentAdd (boost::json::object&& jsonRequest); std::string HandleTorrentRemove (boost::json::object&& jsonRequest); @@ -333,8 +333,7 @@ namespace torrents return boost::json::value(hexHash); } }, - { - "magnetLink", [](std::shared_ptr torrent) + { "magnetLink", [](std::shared_ptr torrent) { std::string hexHash; boost::algorithm::hex (torrent->GetInfoHash ().begin(), torrent->GetInfoHash ().end(), std::back_inserter(hexHash)); @@ -590,7 +589,7 @@ namespace torrents return files; } - std::string_view JSONRPCHandler::RecognizeClientByPeerID (const PeerConnection::PeerID& peerID) + std::string JSONRPCHandler::RecognizeClientByPeerID (const PeerConnection::PeerID& peerID) { static constexpr std::array i2psnark { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x03, 0x03 }; static const std::map twoChars = @@ -617,7 +616,7 @@ namespace torrents { auto it = twoChars.find (peerIDStr.substr (1,2)); if (it != twoChars.end ()) - return it->second; + return std::string (it->second); } else if (peerIDStr.substr (0, 3) == "TIX") return "Tixati";