mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-20 16:43:07 +00:00
web param for torrents tunnel config
This commit is contained in:
@@ -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<bool> (TORRENTS_TUNNEL_DHT, true);
|
||||
bool web = section.second.get<bool> (TORRENTS_TUNNEL_WEB, true);
|
||||
|
||||
// I2CP
|
||||
i2p::util::Mapping options;
|
||||
@@ -1078,7 +1079,8 @@ namespace client
|
||||
else
|
||||
localDestination->SetPublic (true);
|
||||
}
|
||||
auto torrentsTunnel = std::make_shared<i2p::torrents::TorrentsTunnel> (name, localDestination, torrentsDir, trackers, dht);
|
||||
auto torrentsTunnel = std::make_shared<i2p::torrents::TorrentsTunnel> (name,
|
||||
localDestination, torrentsDir, trackers, dht, web);
|
||||
auto [iit, inserted] = m_TorrentsTunnels.emplace (localDestination->GetIdentHash (), torrentsTunnel);
|
||||
if (inserted)
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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 ())
|
||||
|
||||
@@ -25,11 +25,11 @@ namespace i2p
|
||||
namespace torrents
|
||||
{
|
||||
TorrentsTunnel::TorrentsTunnel (std::string_view name, std::shared_ptr<i2p::client::ClientDestination> 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 ();
|
||||
|
||||
@@ -91,7 +91,7 @@ namespace torrents
|
||||
public:
|
||||
|
||||
TorrentsTunnel (std::string_view name, std::shared_ptr<i2p::client::ClientDestination> 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<uint16_t, uint16_t> 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<TorrentsDHT>& 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<uint32_t, std::tuple<size_t, uint16_t, std::weak_ptr<Torrent>, uint64_t > > m_DatragramTrackerTransactions;
|
||||
// transactionID->(trackerID, from_port, torrent, timestamp monotonic milliseconds)
|
||||
std::unique_ptr<TorrentsDHT> m_DHT;
|
||||
bool m_Web;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user