From 0493f00a7abd595729058548c192dd26ef2d247d Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 30 Jun 2016 12:24:26 -0400 Subject: [PATCH 1/4] pass null tunnel config for zero hops tunnel --- Tunnel.cpp | 12 ++++++------ TunnelPool.cpp | 19 ++++++++----------- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/Tunnel.cpp b/Tunnel.cpp index 7983635a..5da18542 100644 --- a/Tunnel.cpp +++ b/Tunnel.cpp @@ -771,18 +771,18 @@ namespace tunnel std::shared_ptr Tunnels::CreateInboundTunnel (std::shared_ptr config, std::shared_ptr outboundTunnel) { - if (config->IsEmpty ()) - return CreateZeroHopsInboundTunnel (); - else + if (config) return CreateTunnel(config, outboundTunnel); + else + return CreateZeroHopsInboundTunnel (); } std::shared_ptr Tunnels::CreateOutboundTunnel (std::shared_ptr config) { - if (config->IsEmpty ()) - return CreateZeroHopsOutboundTunnel (); - else + if (config) return CreateTunnel(config); + else + return CreateZeroHopsOutboundTunnel (); } void Tunnels::AddPendingTunnel (uint32_t replyMsgID, std::shared_ptr tunnel) diff --git a/TunnelPool.cpp b/TunnelPool.cpp index f922853f..7024e1a1 100644 --- a/TunnelPool.cpp +++ b/TunnelPool.cpp @@ -396,8 +396,6 @@ namespace tunnel std::reverse (peers.begin (), peers.end ()); config = std::make_shared (peers); } - else - config = std::make_shared (); auto tunnel = tunnels.CreateInboundTunnel (config, outboundTunnel); tunnel->SetTunnelPool (shared_from_this ()); if (tunnel->IsEstablished ()) // zero hops @@ -413,8 +411,8 @@ namespace tunnel if (!outboundTunnel) outboundTunnel = tunnels.GetNextOutboundTunnel (); LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel..."); - std::shared_ptr config = m_NumInboundHops > 0 ? - std::make_shared(tunnel->GetPeers ()) : std::make_shared (); + std::shared_ptr config; + if (m_NumInboundHops > 0) config = std::make_shared(tunnel->GetPeers ()); auto newTunnel = tunnels.CreateInboundTunnel (config, outboundTunnel); newTunnel->SetTunnelPool (shared_from_this()); if (newTunnel->IsEstablished ()) // zero hops @@ -432,10 +430,9 @@ namespace tunnel std::vector > peers; if (SelectPeers (peers, false)) { - std::shared_ptr config = m_NumOutboundHops > 0 ? - std::make_shared(peers, inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()) : - std::make_shared (); - + std::shared_ptr config; + if (m_NumOutboundHops > 0) + config = std::make_shared(peers, inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()); auto tunnel = tunnels.CreateOutboundTunnel (config); tunnel->SetTunnelPool (shared_from_this ()); if (tunnel->IsEstablished ()) // zero hops @@ -456,9 +453,9 @@ namespace tunnel if (inboundTunnel) { LogPrint (eLogDebug, "Tunnels: Re-creating destination outbound tunnel..."); - std::shared_ptr config = m_NumOutboundHops > 0 ? - std::make_shared(tunnel->GetPeers (), inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()) : - std::make_shared (); + std::shared_ptr config; + if (m_NumOutboundHops > 0) + config = std::make_shared(tunnel->GetPeers (), inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()); auto newTunnel = tunnels.CreateOutboundTunnel (config); newTunnel->SetTunnelPool (shared_from_this ()); if (newTunnel->IsEstablished ()) // zero hops From eab08ea78caffe01831d9322c53fb420036c6689 Mon Sep 17 00:00:00 2001 From: orignal Date: Thu, 30 Jun 2016 13:15:36 -0400 Subject: [PATCH 2/4] don't accept our own RouterInfo --- NetDb.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/NetDb.cpp b/NetDb.cpp index 888e2e7f..1ecf646e 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -450,6 +450,12 @@ namespace data } offset += 32; } + // we must send reply back before this check + if (ident == i2p::context.GetIdentHash ()) + { + LogPrint (eLogError, "NetDb: database store with own RouterInfo received, dropped"); + return; + } size_t payloadOffset = offset; bool updated = false; @@ -489,6 +495,7 @@ namespace data floodMsg->FillI2NPMessageHeader (eI2NPDatabaseStore); std::set excluded; excluded.insert (i2p::context.GetIdentHash ()); // don't flood to itself + excluded.insert (ident); // don't flood back for (int i = 0; i < 3; i++) { auto floodfill = GetClosestFloodfill (ident, excluded); From ff7cf503ae37b62fb0811385ad69917cdebb5e64 Mon Sep 17 00:00:00 2001 From: MXPLRS|Kirill Date: Thu, 30 Jun 2016 21:21:37 +0300 Subject: [PATCH 3/4] added hiding information in webconsole --- HTTPServer.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/HTTPServer.cpp b/HTTPServer.cpp index 9eed80d9..cfcf4261 100644 --- a/HTTPServer.cpp +++ b/HTTPServer.cpp @@ -59,6 +59,8 @@ namespace http { " caption { font-size: 1.5em; text-align: center; color: #894C84; }\r\n" " table { width: 100%; border-collapse: collapse; text-align: center; }\r\n" " .private { background: black; color: black; } .private:hover { background: black; color: white } \r\n" + " .slide p, .slide [type='checkbox']{ display:none; } \r\n" + " .slide [type='checkbox']:checked ~ p { display:block; } \r\n" "\r\n"; const char HTTP_PAGE_TUNNELS[] = "tunnels"; @@ -206,7 +208,10 @@ namespace http { s << numKBytesSent / 1024 / 1024 << " GiB"; s << " (" << (double) i2p::transport::transports.GetOutBandwidth () / 1024 << " KiB/s)
\r\n"; s << "Data path: " << i2p::fs::GetDataDir() << "
\r\n
\r\n"; - s << "Router Ident: " << i2p::context.GetRouterInfo().GetIdentHashBase64()<< "
\r\n"; + s << "
\r\n\r\n

\r\n"; + s << "Router Ident: " << i2p::context.GetRouterInfo().GetIdentHashBase64() << "
\r\n"; + s << "Router Family: " << i2p::context.GetRouterInfo().GetProperty("family") << "
\r\n"; + s << "Router Caps: " << i2p::context.GetRouterInfo().GetProperty("caps") << "
\r\n"; s << "Our external address:" << "
\r\n" ; for (auto address : i2p::context.GetRouterInfo().GetAddresses()) { @@ -229,6 +234,7 @@ namespace http { } s << address->host.to_string() << ":" << address->port << "
\r\n"; } + s << "

\r\n
\r\n"; s << "
\r\nRouters: " << i2p::data::netdb.GetNumRouters () << " "; s << "Floodfills: " << i2p::data::netdb.GetNumFloodfills () << " "; s << "LeaseSets: " << i2p::data::netdb.GetNumLeaseSets () << "
\r\n"; From f62ccc2d480e967d640c830ca7ea69658ee0abc6 Mon Sep 17 00:00:00 2001 From: Jeff Becker Date: Thu, 30 Jun 2016 13:35:36 -0400 Subject: [PATCH 4/4] off by one? --- NetDb.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/NetDb.cpp b/NetDb.cpp index 937ea830..9aa015f7 100644 --- a/NetDb.cpp +++ b/NetDb.cpp @@ -610,7 +610,7 @@ namespace data uint32_t replyTunnelID = 0; if (flag & DATABASE_LOOKUP_DELIVERY_FLAG) //reply to tunnel { - replyTunnelID = bufbe32toh (buf + 64); + replyTunnelID = bufbe32toh (buf + 65); excluded += 4; } uint16_t numExcluded = bufbe16toh (excluded);