From 18d6a2c70ec18c903eaf0952dff001261b103f8e Mon Sep 17 00:00:00 2001 From: orignal Date: Wed, 15 Oct 2014 18:24:40 -0400 Subject: [PATCH] create/delete stream per destination only --- Destination.cpp | 22 ---------------------- Destination.h | 4 ---- HTTPServer.cpp | 4 ++-- I2PTunnel.cpp | 4 ++-- SAM.cpp | 4 ++-- SOCKS.cpp | 2 +- 6 files changed, 7 insertions(+), 33 deletions(-) diff --git a/Destination.cpp b/Destination.cpp index 03e68042..878834b7 100644 --- a/Destination.cpp +++ b/Destination.cpp @@ -453,18 +453,6 @@ namespace stream localDestination->Start (); return localDestination; } - - Stream * StreamingDestinations::CreateClientStream (const i2p::data::LeaseSet& remote) - { - if (!m_SharedLocalDestination) return nullptr; - return m_SharedLocalDestination->CreateNewOutgoingStream (remote); - } - - void StreamingDestinations::DeleteStream (Stream * stream) - { - if (stream) - stream->GetLocalDestination ().DeleteStream (stream); - } StreamingDestination * StreamingDestinations::FindLocalDestination (const i2p::data::IdentHash& destination) const { @@ -474,16 +462,6 @@ namespace stream return nullptr; } - Stream * CreateStream (const i2p::data::LeaseSet& remote) - { - return destinations.CreateClientStream (remote); - } - - void DeleteStream (Stream * stream) - { - destinations.DeleteStream (stream); - } - void StartStreaming () { destinations.Start (); diff --git a/Destination.h b/Destination.h index 200c16be..7c5cad39 100644 --- a/Destination.h +++ b/Destination.h @@ -100,8 +100,6 @@ namespace stream void Start (); void Stop (); - Stream * CreateClientStream (const i2p::data::LeaseSet& remote); - void DeleteStream (Stream * stream); StreamingDestination * GetSharedLocalDestination () const { return m_SharedLocalDestination; }; StreamingDestination * CreateNewLocalDestination (bool isPublic, i2p::data::SigningKeyType sigType); StreamingDestination * CreateNewLocalDestination (const i2p::data::PrivateKeys& keys, bool isPublic); @@ -125,8 +123,6 @@ namespace stream }; - Stream * CreateStream (const i2p::data::LeaseSet& remote); - void DeleteStream (Stream * stream); void StartStreaming (); void StopStreaming (); StreamingDestination * GetSharedLocalDestination (); diff --git a/HTTPServer.cpp b/HTTPServer.cpp index fcbeb7df..5be57604 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -516,7 +516,7 @@ namespace util if (m_Stream) { m_Stream->Close (); - DeleteStream (m_Stream); + i2p::stream::GetSharedLocalDestination ()->DeleteStream (m_Stream); m_Stream = nullptr; } m_Socket->close (); @@ -868,7 +868,7 @@ namespace util } } if (!m_Stream) - m_Stream = i2p::stream::CreateStream (*leaseSet); + m_Stream = i2p::stream::GetSharedLocalDestination ()->CreateNewOutgoingStream (*leaseSet); if (m_Stream) { m_Stream->Send ((uint8_t *)buf, len); diff --git a/I2PTunnel.cpp b/I2PTunnel.cpp index ad584d84..d8b59a33 100644 --- a/I2PTunnel.cpp +++ b/I2PTunnel.cpp @@ -38,7 +38,7 @@ namespace stream if (m_Stream) { m_Stream->Close (); - DeleteStream (m_Stream); + m_Owner->GetLocalDestination ()->DeleteStream (m_Stream); m_Stream = nullptr; } m_Socket->close (); @@ -114,7 +114,7 @@ namespace stream if (ecode != boost::asio::error::operation_aborted) { if (m_Stream) m_Stream->Close (); - DeleteStream (m_Stream); + m_Owner->GetLocalDestination ()->DeleteStream (m_Stream); m_Stream = nullptr; } } diff --git a/SAM.cpp b/SAM.cpp index 3b5e4d51..017eee3e 100644 --- a/SAM.cpp +++ b/SAM.cpp @@ -24,7 +24,7 @@ namespace stream if (m_Stream) { m_Stream->Close (); - DeleteStream (m_Stream); + m_Session->localDestination->DeleteStream (m_Stream); } } @@ -33,7 +33,7 @@ namespace stream if (m_Stream) { m_Stream->Close (); - DeleteStream (m_Stream); + m_Session->localDestination->DeleteStream (m_Stream); m_Stream = nullptr; } switch (m_SocketType) diff --git a/SOCKS.cpp b/SOCKS.cpp index 284337e5..3ec9ab98 100644 --- a/SOCKS.cpp +++ b/SOCKS.cpp @@ -223,7 +223,7 @@ namespace proxy void SOCKS4AHandler::SentConnectionSuccess(const boost::system::error_code & ecode) { LogPrint("--- socks4a making connection"); - m_stream = i2p::stream::CreateStream(*m_ls); + m_stream = i2p::stream::GetSharedLocalDestination ()->CreateNewOutgoingStream(*m_ls); m_state = OKAY; LogPrint("--- socks4a state is ", m_state); AsyncSockRead();