mirror of
https://github.com/PurpleI2P/i2pd
synced 2024-11-10 00:00:29 +03:00
wait until LeaseSet request complete instead timeout
This commit is contained in:
parent
6fb5fa1c52
commit
59aa40e2b0
24
SAM.cpp
24
SAM.cpp
@ -325,9 +325,8 @@ namespace client
|
|||||||
Connect (*leaseSet);
|
Connect (*leaseSet);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_Session->localDestination->RequestDestination (dest.GetIdentHash ());
|
m_Session->localDestination->RequestDestination (dest.GetIdentHash (),
|
||||||
m_Timer.expires_from_now (boost::posix_time::seconds(SAM_CONNECT_TIMEOUT));
|
std::bind (&SAMSocket::HandleLeaseSetRequestComplete,
|
||||||
m_Timer.async_wait (std::bind (&SAMSocket::HandleStreamDestinationRequestTimer,
|
|
||||||
shared_from_this (), std::placeholders::_1, dest.GetIdentHash ()));
|
shared_from_this (), std::placeholders::_1, dest.GetIdentHash ()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -345,18 +344,17 @@ namespace client
|
|||||||
SendMessageReply (SAM_STREAM_STATUS_OK, strlen(SAM_STREAM_STATUS_OK), false);
|
SendMessageReply (SAM_STREAM_STATUS_OK, strlen(SAM_STREAM_STATUS_OK), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void SAMSocket::HandleStreamDestinationRequestTimer (const boost::system::error_code& ecode, i2p::data::IdentHash ident)
|
void SAMSocket::HandleLeaseSetRequestComplete (bool success, i2p::data::IdentHash ident)
|
||||||
{
|
{
|
||||||
if (!ecode) // timeout expired
|
const i2p::data::LeaseSet * leaseSet = nullptr;
|
||||||
|
if (success) // timeout expired
|
||||||
|
leaseSet = m_Session->localDestination->FindLeaseSet (ident);
|
||||||
|
if (leaseSet)
|
||||||
|
Connect (*leaseSet);
|
||||||
|
else
|
||||||
{
|
{
|
||||||
auto leaseSet = m_Session->localDestination->FindLeaseSet (ident);
|
LogPrint ("SAM destination to connect not found");
|
||||||
if (leaseSet)
|
SendMessageReply (SAM_STREAM_STATUS_CANT_REACH_PEER, strlen(SAM_STREAM_STATUS_CANT_REACH_PEER), true);
|
||||||
Connect (*leaseSet);
|
|
||||||
else
|
|
||||||
{
|
|
||||||
LogPrint ("SAM destination to connect not found");
|
|
||||||
SendMessageReply (SAM_STREAM_STATUS_CANT_REACH_PEER, strlen(SAM_STREAM_STATUS_CANT_REACH_PEER), true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
6
SAM.h
6
SAM.h
@ -19,9 +19,7 @@ namespace i2p
|
|||||||
namespace client
|
namespace client
|
||||||
{
|
{
|
||||||
const size_t SAM_SOCKET_BUFFER_SIZE = 4096;
|
const size_t SAM_SOCKET_BUFFER_SIZE = 4096;
|
||||||
const int SAM_SOCKET_CONNECTION_MAX_IDLE = 3600; // in seconds
|
const int SAM_SOCKET_CONNECTION_MAX_IDLE = 3600; // in seconds
|
||||||
const int SAM_CONNECT_TIMEOUT = 5; // in seconds
|
|
||||||
const int SAM_NAMING_LOOKUP_TIMEOUT = 5; // in seconds
|
|
||||||
const int SAM_SESSION_READINESS_CHECK_INTERVAL = 20; // in seconds
|
const int SAM_SESSION_READINESS_CHECK_INTERVAL = 20; // in seconds
|
||||||
const char SAM_HANDSHAKE[] = "HELLO VERSION";
|
const char SAM_HANDSHAKE[] = "HELLO VERSION";
|
||||||
const char SAM_HANDSHAKE_REPLY[] = "HELLO REPLY RESULT=OK VERSION=%s\n";
|
const char SAM_HANDSHAKE_REPLY[] = "HELLO REPLY RESULT=OK VERSION=%s\n";
|
||||||
@ -107,7 +105,7 @@ namespace client
|
|||||||
void ExtractParams (char * buf, size_t len, std::map<std::string, std::string>& params);
|
void ExtractParams (char * buf, size_t len, std::map<std::string, std::string>& params);
|
||||||
|
|
||||||
void Connect (const i2p::data::LeaseSet& remote);
|
void Connect (const i2p::data::LeaseSet& remote);
|
||||||
void HandleStreamDestinationRequestTimer (const boost::system::error_code& ecode, i2p::data::IdentHash ident);
|
void HandleLeaseSetRequestComplete (bool success, i2p::data::IdentHash ident);
|
||||||
void SendNamingLookupReply (const i2p::data::LeaseSet * leaseSet);
|
void SendNamingLookupReply (const i2p::data::LeaseSet * leaseSet);
|
||||||
void SendNamingLookupReply (const i2p::data::IdentityEx& identity);
|
void SendNamingLookupReply (const i2p::data::IdentityEx& identity);
|
||||||
void HandleSessionReadinessCheckTimer (const boost::system::error_code& ecode);
|
void HandleSessionReadinessCheckTimer (const boost::system::error_code& ecode);
|
||||||
|
Loading…
Reference in New Issue
Block a user