diff --git a/libi2pd_client/Torrents.cpp b/libi2pd_client/Torrents.cpp index 287b13bb..4d4a0946 100644 --- a/libi2pd_client/Torrents.cpp +++ b/libi2pd_client/Torrents.cpp @@ -8,13 +8,13 @@ #include #include +#include #include #include #include #include #include #include -#include #include "Log.h" #include "FS.h" #include "I2PEndian.h" @@ -301,14 +301,12 @@ namespace torrents std::string Torrent::GetHexStringInfoHash () const { std::string infoHash; - BIGNUM * bn = BN_bin2bn (m_InfoHash.data (), SHA_DIGEST_LENGTH, nullptr); - char * str = BN_bn2hex (bn); - if (str) + for (auto it: m_InfoHash) { - infoHash = str; - OPENSSL_free (str); + char str[4]; + snprintf (str, 4, "%%%02x", it); + infoHash.append (str); } - BN_free (bn); return infoHash; } @@ -860,6 +858,8 @@ namespace torrents reqURL.create_query (params); auto req = std::make_shared >(boost::beast::http::verb::get, reqURL.to_string (true), 11); // HTTP 1.1 + req->set (boost::beast::http::field::host, reqURL.host); + req->set (boost::beast::http::field::user_agent, "I2PSocketEepGet"); CreateStream ([this, req, torrent](std::shared_ptr stream) { if (stream) diff --git a/libi2pd_client/Torrents.h b/libi2pd_client/Torrents.h index 6cd983dd..7eb064ab 100644 --- a/libi2pd_client/Torrents.h +++ b/libi2pd_client/Torrents.h @@ -102,7 +102,7 @@ namespace torrents size_t GetPieceLength () const { return m_PieceLength; } int GetInterval () const { return m_Interval; } const InfoHash& GetInfoHash () const { return m_InfoHash; } - std::string GetHexStringInfoHash () const; + std::string GetHexStringInfoHash () const; // in url format size_t GetNumPieces () const { return m_Pieces.size (); } Piece& GetPiece (int index) { return m_Pieces[index]; } std::vector CreateBitfield () const;