Browse Source

* sane log messages: Destination.cpp

pull/317/head
hagen 9 years ago
parent
commit
d9e659deb0
  1. 64
      Destination.cpp

64
Destination.cpp

@ -34,7 +34,7 @@ namespace client
if (len > 0) if (len > 0)
{ {
inboundTunnelLen = len; inboundTunnelLen = len;
LogPrint (eLogInfo, "Inbound tunnel length set to ", len); LogPrint (eLogInfo, "Destination: Inbound tunnel length set to ", len);
} }
} }
it = params->find (I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH); it = params->find (I2CP_PARAM_OUTBOUND_TUNNEL_LENGTH);
@ -44,7 +44,7 @@ namespace client
if (len > 0) if (len > 0)
{ {
outboundTunnelLen = len; outboundTunnelLen = len;
LogPrint (eLogInfo, "Outbound tunnel length set to ", len); LogPrint (eLogInfo, "Destination: Outbound tunnel length set to ", len);
} }
} }
it = params->find (I2CP_PARAM_INBOUND_TUNNELS_QUANTITY); it = params->find (I2CP_PARAM_INBOUND_TUNNELS_QUANTITY);
@ -54,7 +54,7 @@ namespace client
if (quantity > 0) if (quantity > 0)
{ {
inboundTunnelsQuantity = quantity; inboundTunnelsQuantity = quantity;
LogPrint (eLogInfo, "Inbound tunnels quantity set to ", quantity); LogPrint (eLogInfo, "Destination: Inbound tunnels quantity set to ", quantity);
} }
} }
it = params->find (I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY); it = params->find (I2CP_PARAM_OUTBOUND_TUNNELS_QUANTITY);
@ -64,7 +64,7 @@ namespace client
if (quantity > 0) if (quantity > 0)
{ {
outboundTunnelsQuantity = quantity; outboundTunnelsQuantity = quantity;
LogPrint (eLogInfo, "Outbound tunnels quantity set to ", quantity); LogPrint (eLogInfo, "Destination: Outbound tunnels quantity set to ", quantity);
} }
} }
it = params->find (I2CP_PARAM_EXPLICIT_PEERS); it = params->find (I2CP_PARAM_EXPLICIT_PEERS);
@ -79,14 +79,14 @@ namespace client
ident.FromBase64 (b64); ident.FromBase64 (b64);
explicitPeers->push_back (ident); explicitPeers->push_back (ident);
} }
LogPrint (eLogInfo, "Explicit peers set to ", it->second); LogPrint (eLogInfo, "Destination: Explicit peers set to ", it->second);
} }
} }
m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inboundTunnelLen, outboundTunnelLen, inboundTunnelsQuantity, outboundTunnelsQuantity); m_Pool = i2p::tunnel::tunnels.CreateTunnelPool (inboundTunnelLen, outboundTunnelLen, inboundTunnelsQuantity, outboundTunnelsQuantity);
if (explicitPeers) if (explicitPeers)
m_Pool->SetExplicitPeers (explicitPeers); m_Pool->SetExplicitPeers (explicitPeers);
if (m_IsPublic) if (m_IsPublic)
LogPrint (eLogInfo, "Local address ", GetIdentHash().ToBase32 (), " created"); LogPrint (eLogInfo, "Destination: Local address ", GetIdentHash().ToBase32 (), " created");
} }
ClientDestination::~ClientDestination () ClientDestination::~ClientDestination ()
@ -112,7 +112,7 @@ namespace client
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {
LogPrint ("Destination: ", ex.what ()); LogPrint (eLogError, "Destination: runtime exception: ", ex.what ());
} }
} }
} }
@ -175,7 +175,7 @@ namespace client
if (it->second->HasNonExpiredLeases ()) if (it->second->HasNonExpiredLeases ())
return it->second; return it->second;
else else
LogPrint ("All leases of remote LeaseSet expired"); LogPrint (eLogWarning, "Destination: All leases of remote LeaseSet expired");
} }
else else
{ {
@ -256,7 +256,7 @@ namespace client
size_t offset = DATABASE_STORE_HEADER_SIZE; size_t offset = DATABASE_STORE_HEADER_SIZE;
if (replyToken) if (replyToken)
{ {
LogPrint (eLogInfo, "Reply token is ignored for DatabaseStore"); LogPrint (eLogInfo, "Destination: Reply token is ignored for DatabaseStore");
offset += 36; offset += 36;
} }
std::shared_ptr<i2p::data::LeaseSet> leaseSet; std::shared_ptr<i2p::data::LeaseSet> leaseSet;
@ -293,7 +293,7 @@ namespace client
} }
} }
else else
LogPrint (eLogError, "Unexpected client's DatabaseStore type ", buf[DATABASE_STORE_TYPE_OFFSET], ". Dropped"); LogPrint (eLogError, "Destination: Unexpected client's DatabaseStore type ", buf[DATABASE_STORE_TYPE_OFFSET], ", dropped");
auto it1 = m_LeaseSetRequests.find (buf + DATABASE_STORE_KEY_OFFSET); auto it1 = m_LeaseSetRequests.find (buf + DATABASE_STORE_KEY_OFFSET);
if (it1 != m_LeaseSetRequests.end ()) if (it1 != m_LeaseSetRequests.end ())
@ -308,7 +308,7 @@ namespace client
{ {
i2p::data::IdentHash key (buf); i2p::data::IdentHash key (buf);
int num = buf[32]; // num int num = buf[32]; // num
LogPrint ("DatabaseSearchReply for ", key.ToBase64 (), " num=", num); LogPrint (eLogDebug, "Destination: DatabaseSearchReply for ", key.ToBase64 (), " num=", num);
auto it = m_LeaseSetRequests.find (key); auto it = m_LeaseSetRequests.find (key);
if (it != m_LeaseSetRequests.end ()) if (it != m_LeaseSetRequests.end ())
{ {
@ -322,21 +322,21 @@ namespace client
auto floodfill = i2p::data::netdb.FindRouter (peerHash); auto floodfill = i2p::data::netdb.FindRouter (peerHash);
if (floodfill) if (floodfill)
{ {
LogPrint (eLogInfo, "Requesting ", key.ToBase64 (), " at ", peerHash.ToBase64 ()); LogPrint (eLogInfo, "Destination: Requesting ", key.ToBase64 (), " at ", peerHash.ToBase64 ());
if (SendLeaseSetRequest (key, floodfill, request)) if (SendLeaseSetRequest (key, floodfill, request))
found = true; found = true;
} }
else else
{ {
LogPrint (eLogInfo, "Found new floodfill. Request it"); LogPrint (eLogInfo, "Destination: Found new floodfill, request it"); // TODO: recheck this message
i2p::data::netdb.RequestDestination (peerHash); i2p::data::netdb.RequestDestination (peerHash);
} }
} }
if (!found) if (!found)
LogPrint (eLogError, "Suggested floodfills are not presented in netDb"); LogPrint (eLogError, "Destination: Suggested floodfills are not presented in netDb");
} }
else else
LogPrint (eLogInfo, key.ToBase64 (), " was not found on ", MAX_NUM_FLOODFILLS_PER_REQUEST," floodfills"); LogPrint (eLogInfo, "Destination: ", key.ToBase64 (), " was not found on ", MAX_NUM_FLOODFILLS_PER_REQUEST, " floodfills");
if (!found) if (!found)
{ {
if (request->requestComplete) request->requestComplete (nullptr); if (request->requestComplete) request->requestComplete (nullptr);
@ -344,7 +344,7 @@ namespace client
} }
} }
else else
LogPrint ("Request for ", key.ToBase64 (), " not found"); LogPrint (eLogWarning, "Destination: Request for ", key.ToBase64 (), " not found");
} }
void ClientDestination::HandleDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg) void ClientDestination::HandleDeliveryStatusMessage (std::shared_ptr<I2NPMessage> msg)
@ -352,7 +352,7 @@ namespace client
uint32_t msgID = bufbe32toh (msg->GetPayload () + DELIVERY_STATUS_MSGID_OFFSET); uint32_t msgID = bufbe32toh (msg->GetPayload () + DELIVERY_STATUS_MSGID_OFFSET);
if (msgID == m_PublishReplyToken) if (msgID == m_PublishReplyToken)
{ {
LogPrint (eLogDebug, "Publishing confirmed"); LogPrint (eLogDebug, "Destination: Publishing LeaseSet confirmed");
m_ExcludedFloodfills.clear (); m_ExcludedFloodfills.clear ();
m_PublishReplyToken = 0; m_PublishReplyToken = 0;
} }
@ -372,30 +372,30 @@ namespace client
{ {
if (!m_LeaseSet || !m_Pool) if (!m_LeaseSet || !m_Pool)
{ {
LogPrint (eLogError, "Can't publish non-existing LeaseSet"); LogPrint (eLogError, "Destination: Can't publish non-existing LeaseSet");
return; return;
} }
if (m_PublishReplyToken) if (m_PublishReplyToken)
{ {
LogPrint (eLogInfo, "Publishing is pending"); LogPrint (eLogDebug, "Destination: Publishing LeaseSet is pending");
return; return;
} }
auto outbound = m_Pool->GetNextOutboundTunnel (); auto outbound = m_Pool->GetNextOutboundTunnel ();
if (!outbound) if (!outbound)
{ {
LogPrint ("Can't publish LeaseSet. No outbound tunnels"); LogPrint (eLogError, "Destination: Can't publish LeaseSet. No outbound tunnels");
return; return;
} }
std::set<i2p::data::IdentHash> excluded; std::set<i2p::data::IdentHash> excluded;
auto floodfill = i2p::data::netdb.GetClosestFloodfill (m_LeaseSet->GetIdentHash (), m_ExcludedFloodfills); auto floodfill = i2p::data::netdb.GetClosestFloodfill (m_LeaseSet->GetIdentHash (), m_ExcludedFloodfills);
if (!floodfill) if (!floodfill)
{ {
LogPrint ("Can't publish LeaseSet. No more floodfills found"); LogPrint (eLogError, "Destination: Can't publish LeaseSet, no more floodfills found");
m_ExcludedFloodfills.clear (); m_ExcludedFloodfills.clear ();
return; return;
} }
m_ExcludedFloodfills.insert (floodfill->GetIdentHash ()); m_ExcludedFloodfills.insert (floodfill->GetIdentHash ());
LogPrint (eLogDebug, "Publish LeaseSet of ", GetIdentHash ().ToBase32 ()); LogPrint (eLogDebug, "Destination: Publish LeaseSet of ", GetIdentHash ().ToBase32 ());
RAND_bytes ((uint8_t *)&m_PublishReplyToken, 4); RAND_bytes ((uint8_t *)&m_PublishReplyToken, 4);
auto msg = WrapMessage (floodfill, i2p::CreateDatabaseStoreMsg (m_LeaseSet, m_PublishReplyToken)); auto msg = WrapMessage (floodfill, i2p::CreateDatabaseStoreMsg (m_LeaseSet, m_PublishReplyToken));
m_PublishConfirmationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_CONFIRMATION_TIMEOUT)); m_PublishConfirmationTimer.expires_from_now (boost::posix_time::seconds(PUBLISH_CONFIRMATION_TIMEOUT));
@ -410,7 +410,7 @@ namespace client
{ {
if (m_PublishReplyToken) if (m_PublishReplyToken)
{ {
LogPrint (eLogWarning, "Publish confirmation was not received in ", PUBLISH_CONFIRMATION_TIMEOUT, "seconds. Try again"); LogPrint (eLogWarning, "Destination: Publish confirmation was not received in ", PUBLISH_CONFIRMATION_TIMEOUT, " seconds, will try again");
m_PublishReplyToken = 0; m_PublishReplyToken = 0;
Publish (); Publish ();
} }
@ -433,7 +433,7 @@ namespace client
if (dest) if (dest)
dest->HandleDataMessagePayload (buf, length); dest->HandleDataMessagePayload (buf, length);
else else
LogPrint ("Missing streaming destination"); LogPrint (eLogError, "Destination: Missing streaming destination");
} }
break; break;
case PROTOCOL_TYPE_DATAGRAM: case PROTOCOL_TYPE_DATAGRAM:
@ -441,10 +441,10 @@ namespace client
if (m_DatagramDestination) if (m_DatagramDestination)
m_DatagramDestination->HandleDataMessagePayload (fromPort, toPort, buf, length); m_DatagramDestination->HandleDataMessagePayload (fromPort, toPort, buf, length);
else else
LogPrint ("Missing streaming destination"); LogPrint (eLogError, "Destination: Missing datagram destination");
break; break;
default: default:
LogPrint ("Data: unexpected protocol ", buf[9]); LogPrint (eLogError, "Destination: Data: unexpected protocol ", buf[9]);
} }
} }
@ -564,23 +564,23 @@ namespace client
} }
else // duplicate else // duplicate
{ {
LogPrint (eLogError, "Request of ", dest.ToBase64 (), " is pending already"); LogPrint (eLogWarning, "Destination: Request of LeaseSet ", dest.ToBase64 (), " is pending already");
// TODO: queue up requests // TODO: queue up requests
if (request->requestComplete) request->requestComplete (nullptr); if (request->requestComplete) request->requestComplete (nullptr);
} }
} }
else else
LogPrint (eLogError, "No floodfills found"); LogPrint (eLogError, "Destination: Can't request LeaseSet, no floodfills found");
} }
bool ClientDestination::SendLeaseSetRequest (const i2p::data::IdentHash& dest, bool ClientDestination::SendLeaseSetRequest (const i2p::data::IdentHash& dest,
std::shared_ptr<const i2p::data::RouterInfo> nextFloodfill, std::shared_ptr<LeaseSetRequest> request) std::shared_ptr<const i2p::data::RouterInfo> nextFloodfill, std::shared_ptr<LeaseSetRequest> request)
{ {
auto replyTunnel = m_Pool->GetNextInboundTunnel (); auto replyTunnel = m_Pool->GetNextInboundTunnel ();
if (!replyTunnel) LogPrint (eLogError, "No inbound tunnels found"); if (!replyTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no inbound tunnels found");
auto outboundTunnel = m_Pool->GetNextOutboundTunnel (); auto outboundTunnel = m_Pool->GetNextOutboundTunnel ();
if (!outboundTunnel) LogPrint (eLogError, "No outbound tunnels found"); if (!outboundTunnel) LogPrint (eLogError, "Destination: Can't send LeaseSet request, no outbound tunnels found");
if (replyTunnel && outboundTunnel) if (replyTunnel && outboundTunnel)
{ {
@ -632,7 +632,7 @@ namespace client
} }
else else
{ {
LogPrint (eLogInfo, dest.ToBase64 (), " was not found within ", MAX_LEASESET_REQUEST_TIMEOUT, " seconds"); LogPrint (eLogWarning, "Destination: ", dest.ToBase64 (), " was not found within ", MAX_LEASESET_REQUEST_TIMEOUT, " seconds");
done = true; done = true;
} }
@ -663,7 +663,7 @@ namespace client
{ {
if (!it->second->HasNonExpiredLeases ()) // all leases expired if (!it->second->HasNonExpiredLeases ()) // all leases expired
{ {
LogPrint ("Remote LeaseSet ", it->second->GetIdentHash ().ToBase64 (), " expired"); LogPrint (eLogWarning, "Destination: Remote LeaseSet ", it->second->GetIdentHash ().ToBase64 (), " expired");
it = m_RemoteLeaseSets.erase (it); it = m_RemoteLeaseSets.erase (it);
} }
else else

Loading…
Cancel
Save