Browse Source

* tune logs

pull/326/head
hagen 9 years ago
parent
commit
05043f30dc
  1. 2
      AddressBook.cpp
  2. 4
      Daemon.cpp
  3. 2
      HTTPServer.cpp
  4. 2
      Log.cpp
  5. 16
      NetDb.cpp
  6. 8
      NetDbRequests.cpp
  7. 73
      SOCKS.cpp
  8. 2
      SSUSession.cpp
  9. 30
      Tunnel.cpp
  10. 2
      TunnelEndpoint.cpp
  11. 2
      TunnelPool.cpp

2
AddressBook.cpp

@ -393,7 +393,7 @@ namespace client
if (!s.length()) continue; // skip empty line if (!s.length()) continue; // skip empty line
m_Subscriptions.push_back (new AddressBookSubscription (*this, s)); m_Subscriptions.push_back (new AddressBookSubscription (*this, s));
} }
LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions loaded"); LogPrint (eLogInfo, "Addressbook: ", m_Subscriptions.size (), " subscriptions urls loaded");
} }
else else
LogPrint (eLogWarning, "Addresbook: subscriptions.txt not found"); LogPrint (eLogWarning, "Addresbook: subscriptions.txt not found");

4
Daemon.cpp

@ -63,8 +63,8 @@ namespace i2p
i2p::util::config::OptionParser(argc, argv); i2p::util::config::OptionParser(argc, argv);
i2p::context.Init (); i2p::context.Init ();
LogPrint(eLogInfo, "\n\n\n\ni2pd v", VERSION, " starting\n"); LogPrint(eLogInfo, "i2pd v", VERSION, " starting");
LogPrint(eLogDebug, "data directory: ", i2p::util::filesystem::GetDataDir().string()); LogPrint(eLogDebug, "FS: data directory: ", i2p::util::filesystem::GetDataDir().string());
i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs); i2p::util::filesystem::ReadConfigFile(i2p::util::config::mapArgs, i2p::util::config::mapMultiArgs);
isDaemon = i2p::util::config::GetArg("-daemon", 0); isDaemon = i2p::util::config::GetArg("-daemon", 0);

2
HTTPServer.cpp

@ -771,7 +771,7 @@ namespace util
void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri) void HTTPConnection::HandleDestinationRequest (const std::string& address, const std::string& uri)
{ {
std::string request = "GET " + uri + " HTTP/1.1\r\nHost:" + address + "\r\n\r\n"; std::string request = "GET " + uri + " HTTP/1.1\r\nHost:" + address + "\r\n\r\n";
LogPrint(eLogDebug, "HTTPServer: client request: ", request); LogPrint(eLogInfo, "HTTPServer: client request: ", request);
SendToAddress (address, 80, request.c_str (), request.size ()); SendToAddress (address, 80, request.c_str (), request.size ());
} }

2
Log.cpp

@ -65,7 +65,7 @@ void Log::SetLogLevel (const std::string& level)
LogPrint(eLogError, "Log: Unknown loglevel: ", level); LogPrint(eLogError, "Log: Unknown loglevel: ", level);
return; return;
} }
LogPrint(eLogInfo, "Log: min msg level set to ", level); LogPrint(eLogInfo, "Log: min messages level set to ", level);
} }
void Log::SetLogStream (std::ostream * logStream) void Log::SetLogStream (std::ostream * logStream)

16
NetDb.cpp

@ -164,14 +164,14 @@ namespace data
auto ts = r->GetTimestamp (); auto ts = r->GetTimestamp ();
r->Update (buf, len); r->Update (buf, len);
if (r->GetTimestamp () > ts) if (r->GetTimestamp () > ts)
LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase32()); LogPrint (eLogInfo, "NetDb: RouterInfo updated: ", ident.ToBase64());
} }
else else
{ {
r = std::make_shared<RouterInfo> (buf, len); r = std::make_shared<RouterInfo> (buf, len);
if (!r->IsUnreachable ()) if (!r->IsUnreachable ())
{ {
LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase32()); LogPrint (eLogInfo, "NetDb: RouterInfo added: ", ident.ToBase64());
{ {
std::unique_lock<std::mutex> l(m_RouterInfosMutex); std::unique_lock<std::mutex> l(m_RouterInfosMutex);
m_RouterInfos[r->GetIdentHash ()] = r; m_RouterInfos[r->GetIdentHash ()] = r;
@ -197,10 +197,10 @@ namespace data
{ {
it->second->Update (buf, len); it->second->Update (buf, len);
if (it->second->IsValid ()) if (it->second->IsValid ())
LogPrint (eLogInfo, "NetDb: LeaseSet updated: ", ident.ToBase32()); LogPrint (eLogInfo, "NetDb: LeaseSet updated: ", ident.ToBase64());
else else
{ {
LogPrint (eLogWarning, "NetDb: LeaseSet update failed: ", ident.ToBase32()); LogPrint (eLogWarning, "NetDb: LeaseSet update failed: ", ident.ToBase64());
m_LeaseSets.erase (it); m_LeaseSets.erase (it);
} }
} }
@ -209,11 +209,11 @@ namespace data
auto leaseSet = std::make_shared<LeaseSet> (buf, len); auto leaseSet = std::make_shared<LeaseSet> (buf, len);
if (leaseSet->IsValid ()) if (leaseSet->IsValid ())
{ {
LogPrint (eLogInfo, "NetDb: LeaseSet added: ", ident.ToBase32()); LogPrint (eLogInfo, "NetDb: LeaseSet added: ", ident.ToBase64());
m_LeaseSets[ident] = leaseSet; m_LeaseSets[ident] = leaseSet;
} }
else else
LogPrint (eLogError, "NetDb: new LeaseSet validation failed: ", ident.ToBase32()); LogPrint (eLogError, "NetDb: new LeaseSet validation failed: ", ident.ToBase64());
} }
} }
} }
@ -435,7 +435,7 @@ namespace data
auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory auto dest = m_Requests.CreateRequest (destination, false, requestComplete); // non-exploratory
if (!dest) if (!dest)
{ {
LogPrint (eLogWarning, "NetDb: destination ", destination.ToBase32(), " is requested already"); LogPrint (eLogWarning, "NetDb: destination ", destination.ToBase64(), " is requested already");
return; return;
} }
@ -444,7 +444,7 @@ namespace data
transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ())); transports.SendMessage (floodfill->GetIdentHash (), dest->CreateRequestMessage (floodfill->GetIdentHash ()));
else else
{ {
LogPrint (eLogError, "NetDb: ", destination.ToBase32(), " destination requested, but no floodfills found"); LogPrint (eLogError, "NetDb: ", destination.ToBase64(), " destination requested, but no floodfills found");
m_Requests.RequestComplete (destination, nullptr); m_Requests.RequestComplete (destination, nullptr);
} }
} }

8
NetDbRequests.cpp

@ -122,15 +122,15 @@ namespace data
else else
{ {
done = true; done = true;
if (!inbound) LogPrint (eLogWarning, "No inbound tunnels"); if (!inbound) LogPrint (eLogWarning, "NetDbReq: No inbound tunnels");
if (!outbound) LogPrint (eLogWarning, "No outbound tunnels"); if (!outbound) LogPrint (eLogWarning, "NetDbReq: No outbound tunnels");
if (!nextFloodfill) LogPrint (eLogWarning, "No more floodfills"); if (!nextFloodfill) LogPrint (eLogWarning, "NetDbReq: No more floodfills");
} }
} }
else else
{ {
if (!dest->IsExploratory ()) if (!dest->IsExploratory ())
LogPrint (eLogWarning, dest->GetDestination ().ToBase64 (), " not found after 7 attempts"); LogPrint (eLogWarning, "NetDbReq: ", dest->GetDestination ().ToBase64 (), " not found after 7 attempts");
done = true; done = true;
} }
} }

73
SOCKS.cpp

@ -145,13 +145,14 @@ namespace proxy
void SOCKSHandler::AsyncSockRead() void SOCKSHandler::AsyncSockRead()
{ {
LogPrint(eLogDebug,"--- SOCKS async sock read"); LogPrint(eLogDebug, "SOCKS: async sock read");
if(m_sock) if (m_sock) {
m_sock->async_receive(boost::asio::buffer(m_sock_buff, socks_buffer_size), m_sock->async_receive(boost::asio::buffer(m_sock_buff, socks_buffer_size),
std::bind(&SOCKSHandler::HandleSockRecv, shared_from_this(), std::bind(&SOCKSHandler::HandleSockRecv, shared_from_this(),
std::placeholders::_1, std::placeholders::_2)); std::placeholders::_1, std::placeholders::_2));
else } else {
LogPrint(eLogError,"--- SOCKS no socket for read"); LogPrint(eLogError,"SOCKS: no socket for read");
}
} }
void SOCKSHandler::Terminate() void SOCKSHandler::Terminate()
@ -159,13 +160,13 @@ namespace proxy
if (Kill()) return; if (Kill()) return;
if (m_sock) if (m_sock)
{ {
LogPrint(eLogDebug,"--- SOCKS close sock"); LogPrint(eLogDebug, "SOCKS: closing socket");
m_sock->close(); m_sock->close();
m_sock = nullptr; m_sock = nullptr;
} }
if (m_stream) if (m_stream)
{ {
LogPrint(eLogDebug,"--- SOCKS close stream"); LogPrint(eLogDebug, "SOCKS: closing stream");
m_stream.reset (); m_stream.reset ();
} }
Done(shared_from_this()); Done(shared_from_this());
@ -216,14 +217,14 @@ namespace proxy
boost::asio::const_buffers_1 response(m_response,2); boost::asio::const_buffers_1 response(m_response,2);
if (m_authchosen == AUTH_UNACCEPTABLE) if (m_authchosen == AUTH_UNACCEPTABLE)
{ {
LogPrint(eLogWarning,"--- SOCKS5 authentication negotiation failed"); LogPrint(eLogWarning, "SOCKS: v5 authentication negotiation failed");
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksFailed, boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksFailed,
shared_from_this(), std::placeholders::_1)); shared_from_this(), std::placeholders::_1));
return false; return false;
} }
else else
{ {
LogPrint(eLogDebug,"--- SOCKS5 choosing authentication method: ", m_authchosen); LogPrint(eLogDebug, "SOCKS: v5 choosing authentication method: ", m_authchosen);
boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksResponse, boost::asio::async_write(*m_sock, response, std::bind(&SOCKSHandler::SentSocksResponse,
shared_from_this(), std::placeholders::_1)); shared_from_this(), std::placeholders::_1));
return true; return true;
@ -238,12 +239,12 @@ namespace proxy
switch (m_socksv) switch (m_socksv)
{ {
case SOCKS4: case SOCKS4:
LogPrint(eLogWarning,"--- SOCKS4 failed: ", error); LogPrint(eLogWarning, "SOCKS: v4 request failed: ", error);
if (error < SOCKS4_OK) error = SOCKS4_FAIL; //Transparently map SOCKS5 errors if (error < SOCKS4_OK) error = SOCKS4_FAIL; //Transparently map SOCKS5 errors
response = GenerateSOCKS4Response(error, m_4aip, m_port); response = GenerateSOCKS4Response(error, m_4aip, m_port);
break; break;
case SOCKS5: case SOCKS5:
LogPrint(eLogWarning,"--- SOCKS5 failed: ", error); LogPrint(eLogWarning, "SOCKS: v5 request failed: ", error);
response = GenerateSOCKS5Response(error, m_addrtype, m_address, m_port); response = GenerateSOCKS5Response(error, m_addrtype, m_address, m_port);
break; break;
} }
@ -258,11 +259,11 @@ namespace proxy
switch (m_socksv) switch (m_socksv)
{ {
case SOCKS4: case SOCKS4:
LogPrint(eLogInfo,"--- SOCKS4 connection success"); LogPrint(eLogInfo, "SOCKS: v4 connection success");
response = GenerateSOCKS4Response(SOCKS4_OK, m_4aip, m_port); response = GenerateSOCKS4Response(SOCKS4_OK, m_4aip, m_port);
break; break;
case SOCKS5: case SOCKS5:
LogPrint(eLogInfo,"--- SOCKS5 connection success"); LogPrint(eLogInfo, "SOCKS: v5 connection success");
auto s = i2p::client::context.GetAddressBook().ToAddress(GetOwner()->GetLocalDestination()->GetIdentHash()); auto s = i2p::client::context.GetAddressBook().ToAddress(GetOwner()->GetLocalDestination()->GetIdentHash());
address ad; ad.dns.FromString(s); address ad; ad.dns.FromString(s);
//HACK only 16 bits passed in port as SOCKS5 doesn't allow for more //HACK only 16 bits passed in port as SOCKS5 doesn't allow for more
@ -293,7 +294,7 @@ namespace proxy
if ( m_cmd != CMD_CONNECT ) if ( m_cmd != CMD_CONNECT )
{ {
//TODO: we need to support binds and other shit! //TODO: we need to support binds and other shit!
LogPrint(eLogError,"--- SOCKS unsupported command: ", m_cmd); LogPrint(eLogError, "SOCKS: unsupported command: ", m_cmd);
SocksRequestFailed(SOCKS5_CMD_UNSUP); SocksRequestFailed(SOCKS5_CMD_UNSUP);
return false; return false;
} }
@ -303,10 +304,10 @@ namespace proxy
switch (m_socksv) switch (m_socksv)
{ {
case SOCKS5: case SOCKS5:
LogPrint(eLogError,"--- SOCKS5 unsupported address type: ", m_addrtype); LogPrint(eLogError, "SOCKS: v5 unsupported address type: ", m_addrtype);
break; break;
case SOCKS4: case SOCKS4:
LogPrint(eLogError,"--- SOCKS4a rejected because it's actually SOCKS4"); LogPrint(eLogError, "SOCKS: request with v4a rejected because it's actually SOCKS4");
break; break;
} }
SocksRequestFailed(SOCKS5_ADDR_UNSUP); SocksRequestFailed(SOCKS5_ADDR_UNSUP);
@ -315,7 +316,7 @@ namespace proxy
//TODO: we may want to support other domains //TODO: we may want to support other domains
if(m_addrtype == ADDR_DNS && m_address.dns.ToString().find(".i2p") == std::string::npos) if(m_addrtype == ADDR_DNS && m_address.dns.ToString().find(".i2p") == std::string::npos)
{ {
LogPrint(eLogError,"--- SOCKS invalid hostname: ", m_address.dns.ToString()); LogPrint(eLogError, "SOCKS: invalid hostname: ", m_address.dns.ToString());
SocksRequestFailed(SOCKS5_ADDR_UNSUP); SocksRequestFailed(SOCKS5_ADDR_UNSUP);
return false; return false;
} }
@ -340,7 +341,7 @@ namespace proxy
EnterState(GET5_AUTHNUM); //Initialize the parser at the right position EnterState(GET5_AUTHNUM); //Initialize the parser at the right position
break; break;
default: default:
LogPrint(eLogError,"--- SOCKS rejected invalid version: ", ((int)*sock_buff)); LogPrint(eLogError, "SOCKS: rejected invalid version: ", ((int)*sock_buff));
Terminate(); Terminate();
return false; return false;
} }
@ -367,7 +368,7 @@ namespace proxy
case CMD_UDP: case CMD_UDP:
if (m_socksv == SOCKS5) break; if (m_socksv == SOCKS5) break;
default: default:
LogPrint(eLogError,"--- SOCKS invalid command: ", ((int)*sock_buff)); LogPrint(eLogError, "SOCKS: invalid command: ", ((int)*sock_buff));
SocksRequestFailed(SOCKS5_GEN_FAIL); SocksRequestFailed(SOCKS5_GEN_FAIL);
return false; return false;
} }
@ -419,7 +420,7 @@ namespace proxy
} }
if (m_address.dns.size >= max_socks_hostname_size) if (m_address.dns.size >= max_socks_hostname_size)
{ {
LogPrint(eLogError,"--- SOCKS4a destination is too large"); LogPrint(eLogError, "SOCKS: v4a req failed: destination is too large");
SocksRequestFailed(SOCKS4_FAIL); SocksRequestFailed(SOCKS4_FAIL);
return false; return false;
} }
@ -428,7 +429,7 @@ namespace proxy
case GET5_REQUESTV: case GET5_REQUESTV:
if (*sock_buff != SOCKS5) if (*sock_buff != SOCKS5)
{ {
LogPrint(eLogError,"--- SOCKS5 rejected unknown request version: ", ((int)*sock_buff)); LogPrint(eLogError,"SOCKS: v5 rejected unknown request version: ", ((int)*sock_buff));
SocksRequestFailed(SOCKS5_GEN_FAIL); SocksRequestFailed(SOCKS5_GEN_FAIL);
return false; return false;
} }
@ -437,7 +438,7 @@ namespace proxy
case GET5_GETRSV: case GET5_GETRSV:
if ( *sock_buff != 0 ) if ( *sock_buff != 0 )
{ {
LogPrint(eLogError,"--- SOCKS5 unknown reserved field: ", ((int)*sock_buff)); LogPrint(eLogError, "SOCKS: v5 unknown reserved field: ", ((int)*sock_buff));
SocksRequestFailed(SOCKS5_GEN_FAIL); SocksRequestFailed(SOCKS5_GEN_FAIL);
return false; return false;
} }
@ -450,7 +451,7 @@ namespace proxy
case ADDR_IPV6: EnterState(GET5_IPV6); break; case ADDR_IPV6: EnterState(GET5_IPV6); break;
case ADDR_DNS : EnterState(GET5_HOST_SIZE); break; case ADDR_DNS : EnterState(GET5_HOST_SIZE); break;
default: default:
LogPrint(eLogError,"--- SOCKS5 unknown address type: ", ((int)*sock_buff)); LogPrint(eLogError, "SOCKS: v5 unknown address type: ", ((int)*sock_buff));
SocksRequestFailed(SOCKS5_GEN_FAIL); SocksRequestFailed(SOCKS5_GEN_FAIL);
return false; return false;
} }
@ -469,7 +470,7 @@ namespace proxy
if (m_parseleft == 0) EnterState(GET_PORT); if (m_parseleft == 0) EnterState(GET_PORT);
break; break;
default: default:
LogPrint(eLogError,"--- SOCKS parse state?? ", m_state); LogPrint(eLogError, "SOCKS: parse state?? ", m_state);
Terminate(); Terminate();
return false; return false;
} }
@ -487,11 +488,11 @@ namespace proxy
void SOCKSHandler::HandleSockRecv(const boost::system::error_code & ecode, std::size_t len) void SOCKSHandler::HandleSockRecv(const boost::system::error_code & ecode, std::size_t len)
{ {
LogPrint(eLogDebug,"--- SOCKS sock recv: ", len); LogPrint(eLogDebug, "SOCKS: recieved ", len, " bytes");
if(ecode) if(ecode)
{ {
LogPrint(eLogWarning," --- SOCKS sock recv got error: ", ecode); LogPrint(eLogWarning, "SOCKS: recv got error: ", ecode);
Terminate(); Terminate();
return; return;
} }
@ -499,7 +500,7 @@ namespace proxy
{ {
if (m_state == DONE) if (m_state == DONE)
{ {
LogPrint(eLogInfo,"--- SOCKS requested ", m_address.dns.ToString(), ":" , m_port); LogPrint(eLogInfo, "SOCKS: requested ", m_address.dns.ToString(), ":" , m_port);
GetOwner()->CreateStream ( std::bind (&SOCKSHandler::HandleStreamRequestComplete, GetOwner()->CreateStream ( std::bind (&SOCKSHandler::HandleStreamRequestComplete,
shared_from_this(), std::placeholders::_1), m_address.dns.ToString(), m_port); shared_from_this(), std::placeholders::_1), m_address.dns.ToString(), m_port);
} }
@ -510,13 +511,9 @@ namespace proxy
void SOCKSHandler::SentSocksFailed(const boost::system::error_code & ecode) void SOCKSHandler::SentSocksFailed(const boost::system::error_code & ecode)
{ {
if (!ecode) if (ecode)
Terminate(); LogPrint (eLogError, "SOCKS: closing socket after sending failure because: ", ecode.message ());
else Terminate();
{
LogPrint (eLogError,"--- SOCKS Closing socket after sending failure because: ", ecode.message ());
Terminate();
}
} }
void SOCKSHandler::SentSocksDone(const boost::system::error_code & ecode) void SOCKSHandler::SentSocksDone(const boost::system::error_code & ecode)
@ -524,7 +521,7 @@ namespace proxy
if (!ecode) if (!ecode)
{ {
if (Kill()) return; if (Kill()) return;
LogPrint (eLogInfo,"--- SOCKS New I2PTunnel connection"); LogPrint (eLogInfo, "SOCKS: new I2PTunnel connection");
auto connection = std::make_shared<i2p::client::I2PTunnelConnection>(GetOwner(), m_sock, m_stream); auto connection = std::make_shared<i2p::client::I2PTunnelConnection>(GetOwner(), m_sock, m_stream);
GetOwner()->AddHandler (connection); GetOwner()->AddHandler (connection);
connection->I2PConnect (m_remaining_data,m_remaining_data_len); connection->I2PConnect (m_remaining_data,m_remaining_data_len);
@ -532,7 +529,7 @@ namespace proxy
} }
else else
{ {
LogPrint (eLogError,"--- SOCKS Closing socket after completion reply because: ", ecode.message ()); LogPrint (eLogError, "SOCKS: closing socket after completion reply because: ", ecode.message ());
Terminate(); Terminate();
} }
} }
@ -541,7 +538,7 @@ namespace proxy
{ {
if (ecode) if (ecode)
{ {
LogPrint (eLogError,"--- SOCKS Closing socket after sending reply because: ", ecode.message ()); LogPrint (eLogError, "SOCKS: closing socket after sending reply because: ", ecode.message ());
Terminate(); Terminate();
} }
} }
@ -555,7 +552,7 @@ namespace proxy
} }
else else
{ {
LogPrint (eLogError,"--- SOCKS Issue when creating the stream, check the previous warnings for more info."); LogPrint (eLogError, "SOCKS: error when creating the stream, check the previous warnings for more info");
SocksRequestFailed(SOCKS5_HOST_UNREACH); SocksRequestFailed(SOCKS5_HOST_UNREACH);
} }
} }

2
SSUSession.cpp

@ -853,7 +853,7 @@ namespace transport
{ {
if (ecode != boost::asio::error::operation_aborted) if (ecode != boost::asio::error::operation_aborted)
{ {
LogPrint (eLogInfo, "SSU: no activity for", SSU_TERMINATION_TIMEOUT, " seconds"); LogPrint (eLogWarning, "SSU: no activity for ", SSU_TERMINATION_TIMEOUT, " seconds");
Failed (); Failed ();
} }
} }

30
Tunnel.cpp

@ -163,7 +163,7 @@ namespace tunnel
void Tunnel::SendTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage> msg) void Tunnel::SendTunnelDataMsg (std::shared_ptr<i2p::I2NPMessage> msg)
{ {
LogPrint (eLogInfo, "Tunnel: Can't send I2NP messages without delivery instructions"); LogPrint (eLogWarning, "Tunnel: Can't send I2NP messages without delivery instructions");
} }
std::vector<std::shared_ptr<const i2p::data::IdentityEx> > Tunnel::GetPeers () const std::vector<std::shared_ptr<const i2p::data::IdentityEx> > Tunnel::GetPeers () const
@ -238,7 +238,7 @@ namespace tunnel
void OutboundTunnel::HandleTunnelDataMsg (std::shared_ptr<const i2p::I2NPMessage> tunnelMsg) void OutboundTunnel::HandleTunnelDataMsg (std::shared_ptr<const i2p::I2NPMessage> tunnelMsg)
{ {
LogPrint (eLogError, "Incoming message for outbound tunnel ", GetTunnelID ()); LogPrint (eLogError, "Tunnel: incoming message for outbound tunnel ", GetTunnelID ());
} }
void OutboundTunnel::Print (std::stringstream& s) const void OutboundTunnel::Print (std::stringstream& s) const
@ -368,7 +368,7 @@ namespace tunnel
std::unique_lock<std::mutex> l(m_TransitTunnelsMutex); std::unique_lock<std::mutex> l(m_TransitTunnelsMutex);
if (!m_TransitTunnels.insert (std::make_pair (tunnel->GetTunnelID (), tunnel)).second) if (!m_TransitTunnels.insert (std::make_pair (tunnel->GetTunnelID (), tunnel)).second)
{ {
LogPrint (eLogError, "Transit tunnel ", tunnel->GetTunnelID (), " already exists"); LogPrint (eLogError, "Tunnel: transit tunnel with id ", tunnel->GetTunnelID (), " already exists");
delete tunnel; delete tunnel;
} }
} }
@ -432,7 +432,7 @@ namespace tunnel
HandleTunnelGatewayMsg (tunnel, msg); HandleTunnelGatewayMsg (tunnel, msg);
} }
else else
LogPrint (eLogWarning, "Tunnel ", tunnelID, " not found"); LogPrint (eLogWarning, "Tunnel: tunnel with id ", tunnelID, " not found");
break; break;
} }
case eI2NPVariableTunnelBuild: case eI2NPVariableTunnelBuild:
@ -442,7 +442,7 @@ namespace tunnel
HandleI2NPMessage (msg->GetBuffer (), msg->GetLength ()); HandleI2NPMessage (msg->GetBuffer (), msg->GetLength ());
break; break;
default: default:
LogPrint (eLogError, "Tunnel: Unexpected messsage type ", (int)typeID); LogPrint (eLogError, "Tunnel: unexpected messsage type ", (int) typeID);
} }
msg = m_Queue.Get (); msg = m_Queue.Get ();
@ -475,7 +475,7 @@ namespace tunnel
{ {
if (!tunnel) if (!tunnel)
{ {
LogPrint (eLogError, "Missing tunnel for TunnelGateway"); LogPrint (eLogError, "Tunnel: missing tunnel for gateway");
return; return;
} }
const uint8_t * payload = msg->GetPayload (); const uint8_t * payload = msg->GetPayload ();
@ -484,7 +484,7 @@ namespace tunnel
msg->offset += I2NP_HEADER_SIZE + TUNNEL_GATEWAY_HEADER_SIZE; msg->offset += I2NP_HEADER_SIZE + TUNNEL_GATEWAY_HEADER_SIZE;
msg->len = msg->offset + len; msg->len = msg->offset + len;
auto typeID = msg->GetTypeID (); auto typeID = msg->GetTypeID ();
LogPrint (eLogDebug, "TunnelGateway of ", (int)len, " bytes for tunnel ", tunnel->GetTunnelID (), ". Msg type ", (int)typeID); LogPrint (eLogDebug, "Tunnel: gateway of ", (int) len, " bytes for tunnel ", tunnel->GetTunnelID (), ", msg type ", (int)typeID);
if (IsRouterInfoMsg (msg) || typeID == eI2NPDatabaseSearchReply) if (IsRouterInfoMsg (msg) || typeID == eI2NPDatabaseSearchReply)
// transit DatabaseStore my contain new/updated RI // transit DatabaseStore my contain new/updated RI
@ -521,7 +521,7 @@ namespace tunnel
case eTunnelStatePending: case eTunnelStatePending:
if (ts > tunnel->GetCreationTime () + TUNNEL_CREATION_TIMEOUT) if (ts > tunnel->GetCreationTime () + TUNNEL_CREATION_TIMEOUT)
{ {
LogPrint (eLogError, "Tunnel: Pending build request ", it->first, " timeout, deleted"); LogPrint (eLogWarning, "Tunnel: pending build request ", it->first, " timeout, deleted");
// update stats // update stats
auto config = tunnel->GetTunnelConfig (); auto config = tunnel->GetTunnelConfig ();
if (config) if (config)
@ -546,7 +546,7 @@ namespace tunnel
it++; it++;
break; break;
case eTunnelStateBuildFailed: case eTunnelStateBuildFailed:
LogPrint (eLogError, "Tunnel: Pending build request ", it->first, " failed, deleted"); LogPrint (eLogError, "Tunnel: pending build request ", it->first, " failed, deleted");
it = pendingTunnels.erase (it); it = pendingTunnels.erase (it);
m_NumFailedTunnelCreations++; m_NumFailedTunnelCreations++;
break; break;
@ -571,7 +571,7 @@ namespace tunnel
auto tunnel = *it; auto tunnel = *it;
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
{ {
LogPrint (eLogDebug, "Tunnel: ", tunnel->GetTunnelID (), " expired"); LogPrint (eLogDebug, "Tunnel: tunnel with id ", tunnel->GetTunnelID (), " expired");
auto pool = tunnel->GetTunnelPool (); auto pool = tunnel->GetTunnelPool ();
if (pool) if (pool)
pool->TunnelExpired (tunnel); pool->TunnelExpired (tunnel);
@ -602,7 +602,7 @@ namespace tunnel
auto inboundTunnel = GetNextInboundTunnel (); auto inboundTunnel = GetNextInboundTunnel ();
auto router = i2p::data::netdb.GetRandomRouter (); auto router = i2p::data::netdb.GetRandomRouter ();
if (!inboundTunnel || !router) return; if (!inboundTunnel || !router) return;
LogPrint (eLogDebug, "Creating one hop outbound tunnel"); LogPrint (eLogDebug, "Tunnel: creating one hop outbound tunnel");
CreateTunnel<OutboundTunnel> ( CreateTunnel<OutboundTunnel> (
std::make_shared<TunnelConfig> (std::vector<std::shared_ptr<const i2p::data::IdentityEx> > { router->GetRouterIdentity () }, std::make_shared<TunnelConfig> (std::vector<std::shared_ptr<const i2p::data::IdentityEx> > { router->GetRouterIdentity () },
inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()) inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ())
@ -619,7 +619,7 @@ namespace tunnel
auto tunnel = it->second; auto tunnel = it->second;
if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) if (ts > tunnel->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
{ {
LogPrint (eLogDebug, "Tunnel: ", tunnel->GetTunnelID (), " expired"); LogPrint (eLogDebug, "Tunnel: tunnel with id ", tunnel->GetTunnelID (), " expired");
auto pool = tunnel->GetTunnelPool (); auto pool = tunnel->GetTunnelPool ();
if (pool) if (pool)
pool->TunnelExpired (tunnel); pool->TunnelExpired (tunnel);
@ -647,7 +647,7 @@ namespace tunnel
if (m_InboundTunnels.empty ()) if (m_InboundTunnels.empty ())
{ {
LogPrint (eLogDebug, "Creating zero hops inbound tunnel..."); LogPrint (eLogDebug, "Tunnel: Creating zero hops inbound tunnel");
CreateZeroHopsInboundTunnel (); CreateZeroHopsInboundTunnel ();
if (!m_ExploratoryPool) if (!m_ExploratoryPool)
{ {
@ -661,7 +661,7 @@ namespace tunnel
{ {
// trying to create one more inbound tunnel // trying to create one more inbound tunnel
auto router = i2p::data::netdb.GetRandomRouter (); auto router = i2p::data::netdb.GetRandomRouter ();
LogPrint (eLogDebug, "Creating one hop inbound tunnel..."); LogPrint (eLogDebug, "Tunnel: creating one hop inbound tunnel");
CreateTunnel<InboundTunnel> ( CreateTunnel<InboundTunnel> (
std::make_shared<TunnelConfig> (std::vector<std::shared_ptr<const i2p::data::IdentityEx> > { router->GetRouterIdentity () }) std::make_shared<TunnelConfig> (std::vector<std::shared_ptr<const i2p::data::IdentityEx> > { router->GetRouterIdentity () })
); );
@ -676,7 +676,7 @@ namespace tunnel
if (ts > it->second->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT) if (ts > it->second->GetCreationTime () + TUNNEL_EXPIRATION_TIMEOUT)
{ {
auto tmp = it->second; auto tmp = it->second;
LogPrint (eLogDebug, "Transit tunnel ", tmp->GetTunnelID (), " expired"); LogPrint (eLogDebug, "Tunnel: Transit tunnel with id ", tmp->GetTunnelID (), " expired");
{ {
std::unique_lock<std::mutex> l(m_TransitTunnelsMutex); std::unique_lock<std::mutex> l(m_TransitTunnelsMutex);
it = m_TransitTunnels.erase (it); it = m_TransitTunnels.erase (it);

2
TunnelEndpoint.cpp

@ -226,7 +226,7 @@ namespace tunnel
void TunnelEndpoint::HandleNextMessage (const TunnelMessageBlock& msg) void TunnelEndpoint::HandleNextMessage (const TunnelMessageBlock& msg)
{ {
auto typeID = msg.data->GetTypeID (); auto typeID = msg.data->GetTypeID ();
LogPrint (eLogInfo, "TunnelMessage: handle fragment of ", msg.data->GetLength ()," bytes. Msg type ", (int)typeID); LogPrint (eLogDebug, "TunnelMessage: handle fragment of ", msg.data->GetLength (), " bytes, msg type ", (int)typeID);
switch (msg.deliveryType) switch (msg.deliveryType)
{ {
case eDeliveryTypeLocal: case eDeliveryTypeLocal:

2
TunnelPool.cpp

@ -203,7 +203,7 @@ namespace tunnel
{ {
for (auto it: m_Tests) for (auto it: m_Tests)
{ {
LogPrint (eLogWarning, "Tunnels: test of ", (int)it.first, " failed"); LogPrint (eLogWarning, "Tunnels: test of tunnel ", it.first, " failed");
// if test failed again with another tunnel we consider it failed // if test failed again with another tunnel we consider it failed
if (it.second.first) if (it.second.first)
{ {

Loading…
Cancel
Save