Browse Source

* sane log messages: Transports.cpp

pull/317/head
hagen 9 years ago
parent
commit
830fe7f9b8
  1. 36
      Transports.cpp

36
Transports.cpp

@ -126,12 +126,12 @@ namespace transport
if (!m_SSUServer) if (!m_SSUServer)
{ {
m_SSUServer = new SSUServer (address.port); m_SSUServer = new SSUServer (address.port);
LogPrint ("Start listening UDP port ", address.port); LogPrint (eLogInfo, "Transports: Start listening UDP port ", address.port);
m_SSUServer->Start (); m_SSUServer->Start ();
DetectExternalIP (); DetectExternalIP ();
} }
else else
LogPrint ("SSU server already exists"); LogPrint (eLogError, "Transports: SSU server already exists");
} }
} }
m_PeerCleanupTimer.expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT)); m_PeerCleanupTimer.expires_from_now (boost::posix_time::seconds(5*SESSION_CREATION_TIMEOUT));
@ -176,7 +176,7 @@ namespace transport
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {
LogPrint ("Transports: ", ex.what ()); LogPrint (eLogError, "Transports: runtime exception: ", ex.what ());
} }
} }
} }
@ -236,7 +236,7 @@ namespace transport
} }
catch (std::exception& ex) catch (std::exception& ex)
{ {
LogPrint (eLogError, "Transports::PostMessages ", ex.what ()); LogPrint (eLogError, "Transports: PostMessages exception:", ex.what ());
} }
if (!connected) return; if (!connected) return;
} }
@ -278,14 +278,14 @@ namespace transport
{ {
if (address->addressString.length () > 0) // trying to resolve if (address->addressString.length () > 0) // trying to resolve
{ {
LogPrint (eLogInfo, "Resolving NTCP ", address->addressString); LogPrint (eLogDebug, "Transports: Resolving NTCP ", address->addressString);
NTCPResolve (address->addressString, ident); NTCPResolve (address->addressString, ident);
return true; return true;
} }
} }
} }
else else
LogPrint (eLogInfo, "NTCP address is not presented. Trying SSU"); LogPrint (eLogWarning, "Transports: NTCP address is not present for ", i2p::data::GetIdentHashAbbreviation (ident), ", trying SSU");
} }
if (peer.numAttempts == 1)// SSU if (peer.numAttempts == 1)// SSU
{ {
@ -308,21 +308,21 @@ namespace transport
{ {
if (address->addressString.length () > 0) // trying to resolve if (address->addressString.length () > 0) // trying to resolve
{ {
LogPrint (eLogInfo, "Resolving SSU ", address->addressString); LogPrint (eLogDebug, "Transports: Resolving SSU ", address->addressString);
SSUResolve (address->addressString, ident); SSUResolve (address->addressString, ident);
return true; return true;
} }
} }
} }
} }
LogPrint (eLogError, "No NTCP and SSU addresses available"); LogPrint (eLogError, "Transports: No NTCP or SSU addresses available");
peer.Done (); peer.Done ();
m_Peers.erase (ident); m_Peers.erase (ident);
return false; return false;
} }
else // otherwise request RI else // otherwise request RI
{ {
LogPrint ("Router not found. Requested"); LogPrint (eLogInfo, "Transports: RouterInfo for ", ident.ToBase64 (), " not found, requested");
i2p::data::netdb.RequestDestination (ident, std::bind ( i2p::data::netdb.RequestDestination (ident, std::bind (
&Transports::RequestComplete, this, std::placeholders::_1, ident)); &Transports::RequestComplete, this, std::placeholders::_1, ident));
} }
@ -341,13 +341,13 @@ namespace transport
{ {
if (r) if (r)
{ {
LogPrint ("Router found. Trying to connect"); LogPrint (eLogDebug, "Transports: RouterInfo for ", ident.ToBase64 (), " found, Trying to connect");
it->second.router = r; it->second.router = r;
ConnectToPeer (ident, it->second); ConnectToPeer (ident, it->second);
} }
else else
{ {
LogPrint ("Router not found. Failed to send messages"); LogPrint (eLogError, "Transports: RouterInfo not found, Failed to send messages");
m_Peers.erase (it); m_Peers.erase (it);
} }
} }
@ -371,7 +371,7 @@ namespace transport
if (!ecode && peer.router) if (!ecode && peer.router)
{ {
auto address = (*it).endpoint ().address (); auto address = (*it).endpoint ().address ();
LogPrint (eLogInfo, (*it).host_name (), " has been resolved to ", address); LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address);
auto addr = peer.router->GetNTCPAddress (); auto addr = peer.router->GetNTCPAddress ();
if (addr) if (addr)
{ {
@ -380,7 +380,7 @@ namespace transport
return; return;
} }
} }
LogPrint (eLogError, "Unable to resolve NTCP address: ", ecode.message ()); LogPrint (eLogError, "Transports: Unable to resolve NTCP address: ", ecode.message ());
m_Peers.erase (it1); m_Peers.erase (it1);
} }
} }
@ -403,7 +403,7 @@ namespace transport
if (!ecode && peer.router) if (!ecode && peer.router)
{ {
auto address = (*it).endpoint ().address (); auto address = (*it).endpoint ().address ();
LogPrint (eLogInfo, (*it).host_name (), " has been resolved to ", address); LogPrint (eLogDebug, "Transports: ", (*it).host_name (), " has been resolved to ", address);
auto addr = peer.router->GetSSUAddress (!context.SupportsV6 ());; auto addr = peer.router->GetSSUAddress (!context.SupportsV6 ());;
if (addr) if (addr)
{ {
@ -411,7 +411,7 @@ namespace transport
return; return;
} }
} }
LogPrint (eLogError, "Unable to resolve SSU address: ", ecode.message ()); LogPrint (eLogError, "Transports: Unable to resolve SSU address: ", ecode.message ());
m_Peers.erase (it1); m_Peers.erase (it1);
} }
} }
@ -428,7 +428,7 @@ namespace transport
if (ssuSession) // try SSU first if (ssuSession) // try SSU first
{ {
m_SSUServer->DeleteSession (ssuSession); m_SSUServer->DeleteSession (ssuSession);
LogPrint ("SSU session closed"); LogPrint (eLogDebug, "Transports: SSU session closed");
} }
// TODO: delete NTCP // TODO: delete NTCP
} }
@ -453,7 +453,7 @@ namespace transport
} }
} }
else else
LogPrint (eLogError, "Can't detect external IP. SSU is not available"); LogPrint (eLogError, "Transports: Can't detect external IP. SSU is not available");
} }
void Transports::PeerTest () void Transports::PeerTest ()
@ -541,7 +541,7 @@ namespace transport
{ {
if (it->second.sessions.empty () && ts > it->second.creationTime + SESSION_CREATION_TIMEOUT) if (it->second.sessions.empty () && ts > it->second.creationTime + SESSION_CREATION_TIMEOUT)
{ {
LogPrint (eLogError, "Session to peer ", it->first.ToBase64 (), " has not been created in ", SESSION_CREATION_TIMEOUT, " seconds"); LogPrint (eLogWarning, "Transports: Session to peer ", it->first.ToBase64 (), " has not been created in ", SESSION_CREATION_TIMEOUT, " seconds");
it = m_Peers.erase (it); it = m_Peers.erase (it);
} }
else else

Loading…
Cancel
Save