From 35db1e0bd23938bee7bda12da3e4163d788a5f3d Mon Sep 17 00:00:00 2001 From: orignal Date: Mon, 12 Oct 2026 12:21:26 -0400 Subject: [PATCH] web param for torrents tunnel config --- libi2pd_client/ClientContext.cpp | 4 +++- libi2pd_client/ClientContext.h | 1 + libi2pd_client/TorrentsRPC.cpp | 2 +- libi2pd_client/TorrentsTunnel.cpp | 4 ++-- libi2pd_client/TorrentsTunnel.h | 4 +++- 5 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libi2pd_client/ClientContext.cpp b/libi2pd_client/ClientContext.cpp index 26d21037..ab5be656 100644 --- a/libi2pd_client/ClientContext.cpp +++ b/libi2pd_client/ClientContext.cpp @@ -1048,6 +1048,7 @@ namespace client i2p::data::SigningKeyType sigType = section.second.get (TORRENTS_TUNNEL_SIGNATURE_TYPE, i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519); if (sigType > i2p::data::SIGNING_KEY_TYPE_REDDSA_SHA512_ED25519) sigType = i2p::data::SIGNING_KEY_TYPE_EDDSA_SHA512_ED25519; bool dht = section.second.get (TORRENTS_TUNNEL_DHT, true); + bool web = section.second.get (TORRENTS_TUNNEL_WEB, true); // I2CP i2p::util::Mapping options; @@ -1078,7 +1079,8 @@ namespace client else localDestination->SetPublic (true); } - auto torrentsTunnel = std::make_shared (name, localDestination, torrentsDir, trackers, dht); + auto torrentsTunnel = std::make_shared (name, + localDestination, torrentsDir, trackers, dht, web); auto [iit, inserted] = m_TorrentsTunnels.emplace (localDestination->GetIdentHash (), torrentsTunnel); if (inserted) { diff --git a/libi2pd_client/ClientContext.h b/libi2pd_client/ClientContext.h index 09fa97f9..d946a3c6 100644 --- a/libi2pd_client/ClientContext.h +++ b/libi2pd_client/ClientContext.h @@ -82,6 +82,7 @@ namespace client const char TORRENTS_TUNNEL_RPC_PATH[] = "rpcpath"; const char TORRENTS_TUNNEL_RPC_ADDRESS[] = "rpcaddress"; const char TORRENTS_TUNNEL_DHT[] = "dht"; + const char TORRENTS_TUNNEL_WEB[] = "web"; constexpr int STOP_DESTINATIONS_TIMEOUT = 8; // in seconds diff --git a/libi2pd_client/TorrentsRPC.cpp b/libi2pd_client/TorrentsRPC.cpp index b37d856c..d2614dda 100644 --- a/libi2pd_client/TorrentsRPC.cpp +++ b/libi2pd_client/TorrentsRPC.cpp @@ -947,7 +947,7 @@ namespace torrents if (subUrlPath != urlPath.end ()) { auto tunnel = m_Server.GetTunnel (subUrlPath->string () + "/rpc"); - if (tunnel) + if (tunnel && tunnel->SupportsWeb ()) { subUrlPath++; if (subUrlPath != urlPath.end ()) diff --git a/libi2pd_client/TorrentsTunnel.cpp b/libi2pd_client/TorrentsTunnel.cpp index e35bdd8c..59eccc17 100644 --- a/libi2pd_client/TorrentsTunnel.cpp +++ b/libi2pd_client/TorrentsTunnel.cpp @@ -25,11 +25,11 @@ namespace i2p namespace torrents { TorrentsTunnel::TorrentsTunnel (std::string_view name, std::shared_ptr localDestination, - std::string_view torrentsDir, std::string_view trackers, bool dht): + std::string_view torrentsDir, std::string_view trackers, bool dht, bool web): i2p::client::I2PService (localDestination), m_Name (name), m_PeerID ("-I2PD-"), m_TorrentsDir (torrentsDir), m_TrackerRequestsCheckTimer (GetService ()), m_KeepAliveCheckTimer (GetService ()), m_ReconnectCheckTimer (GetService ()), - m_TorrentsStatusUpdateTimer (GetService ()) + m_TorrentsStatusUpdateTimer (GetService ()), m_Web (web) { if (localDestination) m_PeerID += localDestination->GetIdentHash ().ToBase64 (); diff --git a/libi2pd_client/TorrentsTunnel.h b/libi2pd_client/TorrentsTunnel.h index ace4dbd1..7989b7f4 100644 --- a/libi2pd_client/TorrentsTunnel.h +++ b/libi2pd_client/TorrentsTunnel.h @@ -91,7 +91,7 @@ namespace torrents public: TorrentsTunnel (std::string_view name, std::shared_ptr localDestination, - std::string_view torrentsDir, std::string_view trackers = "", bool dht = true); + std::string_view torrentsDir, std::string_view trackers = "", bool dht = true, bool web = true); void Start () override; void Stop () override; @@ -119,6 +119,7 @@ namespace torrents std::pair GetDHTPorts () const { return { m_DHT ? m_DHT->GetPort () : 0, m_DHT ? m_DHT->GetRPort () : 0 }; } bool SupportsDHT () const { return (bool)m_DHT; } const std::unique_ptr& GetDHT () const { return m_DHT; } + bool SupportsWeb () const { return m_Web; } const char* GetName() const override { return m_Name.c_str (); } @@ -181,6 +182,7 @@ namespace torrents std::unordered_map, uint64_t > > m_DatragramTrackerTransactions; // transactionID->(trackerID, from_port, torrent, timestamp monotonic milliseconds) std::unique_ptr m_DHT; + bool m_Web; }; }