#ifndef DESTINATION_H__ #define DESTINATION_H__ #include #include #include "Identity.h" #include "TunnelPool.h" #include "CryptoConst.h" #include "LeaseSet.h" #include "Garlic.h" #include "Streaming.h" namespace i2p { namespace stream { class StreamingDestination: public i2p::garlic::GarlicDestination { public: StreamingDestination (bool isPublic); StreamingDestination (const std::string& fullPath, bool isPublic); StreamingDestination (const i2p::data::PrivateKeys& keys, bool isPublic); ~StreamingDestination (); void Start (); void Stop (); bool IsRunning () const { return m_IsRunning; }; i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; }; Stream * CreateNewOutgoingStream (const i2p::data::LeaseSet& remote); void DeleteStream (Stream * stream); void SetAcceptor (const std::function& acceptor) { m_Acceptor = acceptor; }; void ResetAcceptor () { m_Acceptor = nullptr; }; bool IsAcceptorSet () const { return m_Acceptor != nullptr; }; void HandleNextPacket (Packet * packet); void SendTunnelDataMsgs (const std::vector& msgs); void ResetCurrentOutboundTunnel () { m_CurrentOutboundTunnel = nullptr; }; const i2p::data::LeaseSet * FindLeaseSet (const i2p::data::IdentHash& ident); // I2CP void HandleDataMessage (const uint8_t * buf, size_t len); I2NPMessage * CreateDataMessage (const uint8_t * payload, size_t len); // implements LocalDestination const i2p::data::PrivateKeys& GetPrivateKeys () const { return m_Keys; }; const uint8_t * GetEncryptionPrivateKey () const { return m_EncryptionPrivateKey; }; const uint8_t * GetEncryptionPublicKey () const { return m_EncryptionPublicKey; }; // implements GarlicDestination const i2p::data::LeaseSet * GetLeaseSet (); void HandleI2NPMessage (const uint8_t * buf, size_t len); // override GarlicDestination void ProcessGarlicMessage (I2NPMessage * msg); void ProcessDeliveryStatusMessage (I2NPMessage * msg); void SetLeaseSetUpdated (); private: void Run (); Stream * CreateNewIncomingStream (); void UpdateLeaseSet (); void HandleDatabaseStoreMessage (const uint8_t * buf, size_t len); private: bool m_IsRunning; std::thread * m_Thread; boost::asio::io_service m_Service; boost::asio::io_service::work m_Work; std::map m_RemoteLeaseSets; std::mutex m_StreamsMutex; std::map m_Streams; i2p::data::PrivateKeys m_Keys; uint8_t m_EncryptionPublicKey[256], m_EncryptionPrivateKey[256]; i2p::tunnel::TunnelPool * m_Pool; i2p::tunnel::OutboundTunnel * m_CurrentOutboundTunnel; i2p::data::LeaseSet * m_LeaseSet; bool m_IsPublic; std::function m_Acceptor; public: // for HTTP only const decltype(m_Streams)& GetStreams () const { return m_Streams; }; }; class StreamingDestinations { public: StreamingDestinations (): m_SharedLocalDestination (nullptr) {}; ~StreamingDestinations () {}; void Start (); void Stop (); Stream * CreateClientStream (const i2p::data::LeaseSet& remote); void DeleteStream (Stream * stream); StreamingDestination * GetSharedLocalDestination () const { return m_SharedLocalDestination; }; StreamingDestination * CHTTP/1.1 200 OK Content-Disposition: inline; filename="Destination.h"; filename*=UTF-8''Destination.h Content-Length: 4869 Set-Cookie: i_like_gitea=2b3415f9703e01fc; Path=/; HttpOnly; Secure; SameSite=Lax Set-Cookie: _csrf=xJXYgRFNrwoYKjwCwOD3HsTRTeM6MTc1MzI1NTE0ODY0MDE3MzMyNA; Path=/; Max-Age=86400; HttpOnly; Secure; SameSite=Lax Content-Type: text/plain; charset=utf-8 Access-Control-Expose-Headers: Content-Disposition Last-Modified: Mon, 13 Oct 2014 15:21:57 GMT X-Content-Type-Options: nosniff Etag: "e921f4a9772e9d06097fa88541849c9ae6723d6b" X-Frame-Options: SAMEORIGIN Date: Wed, 23 Jul 2025 07:19:08 GMT Connection: close Cache-Control: public, max-age=21600, no-transform X-Cache-Status: HIT X-Cache-Age: 0 #ifndef DESTINATION_H__ #define DESTINATION_H__ #include #include #include "Identity.h" #include "TunnelPool.h" #include "CryptoConst.h" #include "LeaseSet.h" #include "Garlic.h" #include "Streaming.h" namespace i2p { namespace stream { class StreamingDestination: public i2p::garlic::GarlicDestination { public: StreamingDestination (bool isPublic); StreamingDestination (const std::string& fullPath, bool isPublic); StreamingDestination (const i2p::data::PrivateKeys& keys, bool isPublic); ~StreamingDestination (); void Start (); void Stop (); bool IsRunning () const { return m_IsRunning; }; i2p::tunnel::TunnelPool * GetTunnelPool () const { return m_Pool; }; Stream *