info_hash in url format. Host and User-Agent in request

This commit is contained in:
orignal
2026-07-26 15:55:30 -04:00
parent 8101ae4c31
commit 178138e87e
2 changed files with 8 additions and 8 deletions
+7 -7
View File
@@ -8,13 +8,13 @@
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include <charconv>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <functional>
#include <boost/algorithm/string.hpp>
#include <openssl/bn.h>
#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::request<boost::beast::http::string_body> >(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<i2p::stream::Stream> stream)
{
if (stream)
+1 -1
View File
@@ -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<uint8_t> CreateBitfield () const;