|
|
@ -10,7 +10,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
namespace i2p |
|
|
|
namespace i2p |
|
|
|
{ |
|
|
|
{ |
|
|
|
namespace stream |
|
|
|
namespace client |
|
|
|
{ |
|
|
|
{ |
|
|
|
const size_t I2P_TUNNEL_CONNECTION_BUFFER_SIZE = 8192; |
|
|
|
const size_t I2P_TUNNEL_CONNECTION_BUFFER_SIZE = 8192; |
|
|
|
const int I2P_TUNNEL_CONNECTION_MAX_IDLE = 3600; // in seconds
|
|
|
|
const int I2P_TUNNEL_CONNECTION_MAX_IDLE = 3600; // in seconds
|
|
|
@ -23,7 +23,7 @@ namespace stream |
|
|
|
|
|
|
|
|
|
|
|
I2PTunnelConnection (I2PTunnel * owner, boost::asio::ip::tcp::socket * socket, |
|
|
|
I2PTunnelConnection (I2PTunnel * owner, boost::asio::ip::tcp::socket * socket, |
|
|
|
const i2p::data::LeaseSet * leaseSet); |
|
|
|
const i2p::data::LeaseSet * leaseSet); |
|
|
|
I2PTunnelConnection (I2PTunnel * owner, Stream * stream, boost::asio::ip::tcp::socket * socket, |
|
|
|
I2PTunnelConnection (I2PTunnel * owner, i2p::stream::Stream * stream, boost::asio::ip::tcp::socket * socket, |
|
|
|
const boost::asio::ip::tcp::endpoint& target); |
|
|
|
const boost::asio::ip::tcp::endpoint& target); |
|
|
|
~I2PTunnelConnection (); |
|
|
|
~I2PTunnelConnection (); |
|
|
|
|
|
|
|
|
|
|
@ -43,7 +43,7 @@ namespace stream |
|
|
|
|
|
|
|
|
|
|
|
uint8_t m_Buffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE], m_StreamBuffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE]; |
|
|
|
uint8_t m_Buffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE], m_StreamBuffer[I2P_TUNNEL_CONNECTION_BUFFER_SIZE]; |
|
|
|
boost::asio::ip::tcp::socket * m_Socket; |
|
|
|
boost::asio::ip::tcp::socket * m_Socket; |
|
|
|
Stream * m_Stream; |
|
|
|
i2p::stream::Stream * m_Stream; |
|
|
|
I2PTunnel * m_Owner; |
|
|
|
I2PTunnel * m_Owner; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -51,22 +51,22 @@ namespace stream |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
I2PTunnel (boost::asio::io_service& service, StreamingDestination * localDestination): |
|
|
|
I2PTunnel (boost::asio::io_service& service, i2p::stream::StreamingDestination * localDestination): |
|
|
|
m_Service (service), m_LocalDestination (localDestination) {}; |
|
|
|
m_Service (service), m_LocalDestination (localDestination) {}; |
|
|
|
virtual ~I2PTunnel () { ClearConnections (); }; |
|
|
|
virtual ~I2PTunnel () { ClearConnections (); }; |
|
|
|
|
|
|
|
|
|
|
|
void AddConnection (I2PTunnelConnection * conn); |
|
|
|
void AddConnection (I2PTunnelConnection * conn); |
|
|
|
void RemoveConnection (I2PTunnelConnection * conn); |
|
|
|
void RemoveConnection (I2PTunnelConnection * conn); |
|
|
|
void ClearConnections (); |
|
|
|
void ClearConnections (); |
|
|
|
StreamingDestination * GetLocalDestination () { return m_LocalDestination; }; |
|
|
|
i2p::stream::StreamingDestination * GetLocalDestination () { return m_LocalDestination; }; |
|
|
|
void SetLocalDestination (StreamingDestination * dest) { m_LocalDestination = dest; }; |
|
|
|
void SetLocalDestination (i2p::stream::StreamingDestination * dest) { m_LocalDestination = dest; }; |
|
|
|
|
|
|
|
|
|
|
|
boost::asio::io_service& GetService () { return m_Service; }; |
|
|
|
boost::asio::io_service& GetService () { return m_Service; }; |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
boost::asio::io_service& m_Service; |
|
|
|
boost::asio::io_service& m_Service; |
|
|
|
StreamingDestination * m_LocalDestination; |
|
|
|
i2p::stream::StreamingDestination * m_LocalDestination; |
|
|
|
std::set<I2PTunnelConnection *> m_Connections; |
|
|
|
std::set<I2PTunnelConnection *> m_Connections; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
@ -75,7 +75,7 @@ namespace stream |
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
I2PClientTunnel (boost::asio::io_service& service, const std::string& destination, int port, |
|
|
|
I2PClientTunnel (boost::asio::io_service& service, const std::string& destination, int port, |
|
|
|
StreamingDestination * localDestination = nullptr); |
|
|
|
i2p::stream::StreamingDestination * localDestination = nullptr); |
|
|
|
~I2PClientTunnel (); |
|
|
|
~I2PClientTunnel (); |
|
|
|
|
|
|
|
|
|
|
|
void Start (); |
|
|
|
void Start (); |
|
|
@ -102,7 +102,7 @@ namespace stream |
|
|
|
public: |
|
|
|
public: |
|
|
|
|
|
|
|
|
|
|
|
I2PServerTunnel (boost::asio::io_service& service, const std::string& address, int port, |
|
|
|
I2PServerTunnel (boost::asio::io_service& service, const std::string& address, int port, |
|
|
|
StreamingDestination * localDestination); |
|
|
|
i2p::stream::StreamingDestination * localDestination); |
|
|
|
|
|
|
|
|
|
|
|
void Start (); |
|
|
|
void Start (); |
|
|
|
void Stop (); |
|
|
|
void Stop (); |
|
|
@ -110,7 +110,7 @@ namespace stream |
|
|
|
private: |
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|
void Accept (); |
|
|
|
void Accept (); |
|
|
|
void HandleAccept (Stream * stream); |
|
|
|
void HandleAccept (i2p::stream::Stream * stream); |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
|
|
|
|
|
|
|
|