mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2025-01-22 13:27:17 +01:00
Migrate to I2Pservice
This commit is contained in:
parent
dd42819a2f
commit
90005c8237
|
@ -387,18 +387,6 @@ namespace client
|
|||
}
|
||||
}
|
||||
|
||||
void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port) {
|
||||
assert(streamRequestComplete);
|
||||
i2p::data::IdentHash identHash;
|
||||
if (i2p::client::context.GetAddressBook ().GetIdentHash (dest, identHash))
|
||||
CreateStream (streamRequestComplete, identHash, port);
|
||||
else
|
||||
{
|
||||
LogPrint (eLogWarning, "Remote destination ", dest, " not found");
|
||||
streamRequestComplete (nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, int port) {
|
||||
assert(streamRequestComplete);
|
||||
const i2p::data::LeaseSet * leaseSet = FindLeaseSet (dest);
|
||||
|
|
|
@ -36,7 +36,9 @@ namespace client
|
|||
const char I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH[] = "outbound.length";
|
||||
const int DEFAULT_OUTBOUND_TUNNEL_LENGTH = 3;
|
||||
const int STREAM_REQUEST_TIMEOUT = 60; //in seconds
|
||||
|
||||
|
||||
typedef std::function<void (std::shared_ptr<i2p::stream::Stream> stream)> StreamRequestComplete;
|
||||
|
||||
class ClientDestination: public i2p::garlic::GarlicDestination
|
||||
{
|
||||
typedef std::function<void (bool success)> RequestComplete;
|
||||
|
@ -49,7 +51,6 @@ namespace client
|
|||
RequestComplete requestComplete;
|
||||
};
|
||||
|
||||
typedef std::function<void (std::shared_ptr<i2p::stream::Stream> stream)> StreamRequestComplete;
|
||||
|
||||
public:
|
||||
|
||||
|
@ -67,7 +68,6 @@ namespace client
|
|||
|
||||
// streaming
|
||||
i2p::stream::StreamingDestination * GetStreamingDestination () const { return m_StreamingDestination; };
|
||||
void CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port = 0);
|
||||
void CreateStream (StreamRequestComplete streamRequestComplete, const i2p::data::IdentHash& dest, int port = 0);
|
||||
std::shared_ptr<i2p::stream::Stream> CreateStream (const i2p::data::LeaseSet& remote, int port = 0);
|
||||
void AcceptStreams (const i2p::stream::StreamingDestination::Acceptor& acceptor);
|
||||
|
|
|
@ -196,8 +196,7 @@ namespace proxy
|
|||
if (HandleData(m_http_buff, len)) {
|
||||
if (m_state == DONE) {
|
||||
LogPrint(eLogInfo,"--- HTTP Proxy requested: ", m_url);
|
||||
GetOwner()->GetLocalDestination ()->CreateStream (
|
||||
std::bind (&HTTPProxyHandler::HandleStreamRequestComplete,
|
||||
GetOwner()->CreateStream (std::bind (&HTTPProxyHandler::HandleStreamRequestComplete,
|
||||
this, std::placeholders::_1), m_address, m_port);
|
||||
} else {
|
||||
AsyncSockRead();
|
||||
|
|
|
@ -15,5 +15,17 @@ namespace client
|
|||
i2p::client::context.CreateNewLocalDestination (false, I2P_SERVICE_DEFAULT_KEY_TYPE))
|
||||
{
|
||||
}
|
||||
|
||||
void ClientDestination::CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port) {
|
||||
assert(streamRequestComplete);
|
||||
i2p::data::IdentHash identHash;
|
||||
if (i2p::client::context.GetAddressBook ().GetIdentHash (dest, identHash))
|
||||
localDestination->CreateStream (streamRequestComplete, identHash, port);
|
||||
else
|
||||
{
|
||||
LogPrint (eLogWarning, "Remote destination ", dest, " not found");
|
||||
streamRequestComplete (nullptr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ namespace client
|
|||
|
||||
inline ClientDestination * GetLocalDestination () { return m_LocalDestination; };
|
||||
inline void SetLocalDestination (ClientDestination * dest) { m_LocalDestination = dest; };
|
||||
void CreateStream (StreamRequestComplete streamRequestComplete, const std::string& dest, int port = 0);
|
||||
|
||||
inline boost::asio::io_service& GetService () { return m_LocalDestination->GetService (); };
|
||||
|
||||
|
|
|
@ -454,8 +454,7 @@ namespace proxy
|
|||
if (HandleData(m_sock_buff, len)) {
|
||||
if (m_state == DONE) {
|
||||
LogPrint(eLogInfo,"--- SOCKS requested ", m_address.dns.ToString(), ":" , m_port);
|
||||
GetOwner()->GetLocalDestination ()->CreateStream (
|
||||
std::bind (&SOCKSHandler::HandleStreamRequestComplete,
|
||||
GetOwner()->CreateStream ( std::bind (&SOCKSHandler::HandleStreamRequestComplete,
|
||||
this, std::placeholders::_1), m_address.dns.ToString(), m_port);
|
||||
} else {
|
||||
AsyncSockRead();
|
||||
|
|
Loading…
Reference in a new issue