Browse Source

Migrate to I2Pservice

pull/143/head
Francisco Blas (klondike) Izquierdo Riera 10 years ago
parent
commit
90005c8237
  1. 12
      Destination.cpp
  2. 6
      Destination.h
  3. 3
      HTTPProxy.cpp
  4. 12
      I2PService.cpp
  5. 1
      I2PService.h
  6. 3
      SOCKS.cpp

12
Destination.cpp

@ -387,18 +387,6 @@ namespace client @@ -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);

6
Destination.h

@ -36,7 +36,9 @@ namespace client @@ -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 @@ -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 @@ -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);

3
HTTPProxy.cpp

@ -196,8 +196,7 @@ namespace proxy @@ -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();

12
I2PService.cpp

@ -15,5 +15,17 @@ namespace client @@ -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);
}
}
}
}

1
I2PService.h

@ -35,6 +35,7 @@ namespace client @@ -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 (); };

3
SOCKS.cpp

@ -454,8 +454,7 @@ namespace proxy @@ -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…
Cancel
Save