mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
36939898fe
Some checks are pending
Build Debian packages / ${{ matrix.dist }} (bookworm) (push) Waiting to run
Build Debian packages / ${{ matrix.dist }} (bullseye) (push) Waiting to run
Build Debian packages / ${{ matrix.dist }} (buster) (push) Waiting to run
Build on FreeBSD / with UPnP (push) Waiting to run
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (no) (push) Waiting to run
Build on OSX / With USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Waiting to run
Build on Windows / ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (clang-x86_64, x64-clang, clang, CLANG64) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (i686, x86, gcc, MINGW32) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (ucrt-x86_64, x64-ucrt, gcc, UCRT64) (push) Waiting to run
Build on Windows / CMake ${{ matrix.arch }} (x86_64, x64, gcc, MINGW64) (push) Waiting to run
Build on Windows / XP (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (no) (push) Waiting to run
Build on Ubuntu / Make with USE_UPNP=${{ matrix.with_upnp }} (yes) (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (OFF) (push) Waiting to run
Build on Ubuntu / CMake with -DWITH_UPNP=${{ matrix.with_upnp }} (ON) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (armv7, linux/arm/v7) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (i386, linux/386) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (amd64, linux/amd64) (push) Waiting to run
Build containers / Building container for ${{ matrix.platform }} (arm64, linux/arm64) (push) Waiting to run
Build containers / Pushing merged manifest (push) Blocked by required conditions
72 lines
2 KiB
C++
72 lines
2 KiB
C++
/*
|
|
* Copyright (c) 2024, The PurpleI2P Project
|
|
*
|
|
* This file is part of Purple i2pd project and licensed under BSD3
|
|
*
|
|
* See full license text in LICENSE file at top of project tree
|
|
*
|
|
*/
|
|
|
|
#include "Transports.h"
|
|
#include "TunnelBase.h"
|
|
|
|
namespace i2p
|
|
{
|
|
namespace tunnel
|
|
{
|
|
void TunnelTransportSender::SendMessagesTo (const i2p::data::IdentHash& to,
|
|
std::list<std::shared_ptr<I2NPMessage> >&& msgs)
|
|
{
|
|
if (msgs.empty ()) return;
|
|
auto currentTransport = m_CurrentTransport.lock ();
|
|
if (!currentTransport)
|
|
{
|
|
// try to obtain transport from pending request or send thought transport is not complete
|
|
if (m_PendingTransport.valid ()) // pending request?
|
|
{
|
|
if (m_PendingTransport.wait_for(std::chrono::seconds(0)) == std::future_status::ready)
|
|
{
|
|
// pending request complete
|
|
currentTransport = m_PendingTransport.get (); // take transports used in pending request
|
|
if (currentTransport)
|
|
{
|
|
if (currentTransport->IsEstablished ())
|
|
m_CurrentTransport = currentTransport;
|
|
else
|
|
currentTransport = nullptr;
|
|
}
|
|
}
|
|
else // still pending
|
|
{
|
|
// send through transports, but don't update pending transport
|
|
i2p::transport::transports.SendMessages (to, std::move (msgs));
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
if (currentTransport) // session is good
|
|
// send to session directly
|
|
currentTransport->SendI2NPMessages (msgs);
|
|
else // no session yet
|
|
// send through transports
|
|
m_PendingTransport = i2p::transport::transports.SendMessages (to, std::move (msgs));
|
|
|
|
}
|
|
|
|
void TunnelTransportSender::SendMessagesTo (const i2p::data::IdentHash& to,
|
|
std::list<std::shared_ptr<I2NPMessage> >& msgs)
|
|
{
|
|
std::list<std::shared_ptr<i2p::I2NPMessage> > msgs1;
|
|
msgs.swap (msgs1);
|
|
SendMessagesTo (to, std::move (msgs1));
|
|
}
|
|
|
|
void TunnelTransportSender::Reset ()
|
|
{
|
|
m_CurrentTransport.reset ();
|
|
if (m_PendingTransport.valid ())
|
|
m_PendingTransport = std::future<std::shared_ptr<i2p::transport::TransportSession> >();
|
|
}
|
|
}
|
|
}
|