Browse Source

Merge branch 'master' into meshnet

pull/557/head
Jeff Becker 8 years ago
parent
commit
c53d6d80ba
No known key found for this signature in database
GPG Key ID: AB950234D6EA286B
  1. 4
      Destination.cpp
  2. 5
      HTTP.cpp
  3. 1
      Tunnel.cpp
  4. 29
      TunnelPool.cpp

4
Destination.cpp

@ -31,7 +31,7 @@ namespace client
{ {
int len = i2p::util::lexical_cast<int>(it->second, inboundTunnelLen); int len = i2p::util::lexical_cast<int>(it->second, inboundTunnelLen);
if (len > 0) if (len >= 0)
{ {
inboundTunnelLen = len; inboundTunnelLen = len;
} }
@ -42,7 +42,7 @@ namespace client
{ {
int len = i2p::util::lexical_cast<int>(it->second, outboundTunnelLen); int len = i2p::util::lexical_cast<int>(it->second, outboundTunnelLen);
if (len > 0) if (len >= 0)
{ {
outboundTunnelLen = len; outboundTunnelLen = len;
} }

5
HTTP.cpp

@ -85,7 +85,8 @@ namespace http {
} }
/* user[:pass] */ /* user[:pass] */
pos_c = url.find('@', pos_p); pos_c = url.find('@', pos_p);
if (pos_c != std::string::npos) { std::size_t pos_slash = url.find('/', pos_p);
if (pos_c != std::string::npos && (pos_slash == std::string::npos || pos_slash > pos_c)) {
std::size_t delim = url.find(':', pos_p); std::size_t delim = url.find(':', pos_p);
if (delim != std::string::npos && delim < pos_c) { if (delim != std::string::npos && delim < pos_c) {
user = url.substr(pos_p, delim - pos_p); user = url.substr(pos_p, delim - pos_p);
@ -94,7 +95,7 @@ namespace http {
} else { } else {
user = url.substr(pos_p, pos_c - pos_p); user = url.substr(pos_p, pos_c - pos_p);
} }
pos_p = pos_c + 1; pos_p = pos_c + 1;
} }
/* hostname[:port][/path] */ /* hostname[:port][/path] */
pos_c = url.find_first_of(":/", pos_p); pos_c = url.find_first_of(":/", pos_p);

1
Tunnel.cpp

@ -217,6 +217,7 @@ namespace tunnel
if (msg) if (msg)
{ {
m_NumReceivedBytes += msg->GetLength (); m_NumReceivedBytes += msg->GetLength ();
msg->from = shared_from_this ();
HandleI2NPMessage (msg); HandleI2NPMessage (msg);
} }
} }

29
TunnelPool.cpp

@ -387,8 +387,15 @@ namespace tunnel
std::vector<std::shared_ptr<const i2p::data::IdentityEx> > peers; std::vector<std::shared_ptr<const i2p::data::IdentityEx> > peers;
if (SelectPeers (peers, true)) if (SelectPeers (peers, true))
{ {
std::reverse (peers.begin (), peers.end ()); std::shared_ptr<TunnelConfig> config;
auto tunnel = tunnels.CreateInboundTunnel (std::make_shared<TunnelConfig> (peers), outboundTunnel); if (m_NumInboundHops > 0)
{
std::reverse (peers.begin (), peers.end ());
config = std::make_shared<TunnelConfig> (peers);
}
else
config = std::make_shared<ZeroHopsTunnelConfig> ();
auto tunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
tunnel->SetTunnelPool (shared_from_this ()); tunnel->SetTunnelPool (shared_from_this ());
if (tunnel->IsEstablished ()) // zero hops if (tunnel->IsEstablished ()) // zero hops
TunnelCreated (tunnel); TunnelCreated (tunnel);
@ -403,7 +410,9 @@ namespace tunnel
if (!outboundTunnel) if (!outboundTunnel)
outboundTunnel = tunnels.GetNextOutboundTunnel (); outboundTunnel = tunnels.GetNextOutboundTunnel ();
LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel..."); LogPrint (eLogDebug, "Tunnels: Re-creating destination inbound tunnel...");
auto newTunnel = tunnels.CreateInboundTunnel (std::make_shared<TunnelConfig>(tunnel->GetPeers ()), outboundTunnel); std::shared_ptr<TunnelConfig> config = m_NumInboundHops > 0 ?
std::make_shared<TunnelConfig>(tunnel->GetPeers ()) : std::make_shared<ZeroHopsTunnelConfig> ();
auto newTunnel = tunnels.CreateInboundTunnel (config, outboundTunnel);
newTunnel->SetTunnelPool (shared_from_this()); newTunnel->SetTunnelPool (shared_from_this());
if (newTunnel->IsEstablished ()) // zero hops if (newTunnel->IsEstablished ()) // zero hops
TunnelCreated (newTunnel); TunnelCreated (newTunnel);
@ -420,8 +429,11 @@ namespace tunnel
std::vector<std::shared_ptr<const i2p::data::IdentityEx> > peers; std::vector<std::shared_ptr<const i2p::data::IdentityEx> > peers;
if (SelectPeers (peers, false)) if (SelectPeers (peers, false))
{ {
auto tunnel = tunnels.CreateOutboundTunnel ( std::shared_ptr<TunnelConfig> config = m_NumOutboundHops > 0 ?
std::make_shared<TunnelConfig> (peers, inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ())); std::make_shared<TunnelConfig>(peers, inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()) :
std::make_shared<ZeroHopsTunnelConfig> ();
auto tunnel = tunnels.CreateOutboundTunnel (config);
tunnel->SetTunnelPool (shared_from_this ()); tunnel->SetTunnelPool (shared_from_this ());
if (tunnel->IsEstablished ()) // zero hops if (tunnel->IsEstablished ()) // zero hops
TunnelCreated (tunnel); TunnelCreated (tunnel);
@ -441,9 +453,10 @@ namespace tunnel
if (inboundTunnel) if (inboundTunnel)
{ {
LogPrint (eLogDebug, "Tunnels: Re-creating destination outbound tunnel..."); LogPrint (eLogDebug, "Tunnels: Re-creating destination outbound tunnel...");
auto newTunnel = tunnels.CreateOutboundTunnel ( std::shared_ptr<TunnelConfig> config = m_NumOutboundHops > 0 ?
std::make_shared<TunnelConfig> (tunnel->GetPeers (), std::make_shared<TunnelConfig>(tunnel->GetPeers (), inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ()) :
inboundTunnel->GetNextTunnelID (), inboundTunnel->GetNextIdentHash ())); std::make_shared<ZeroHopsTunnelConfig> ();
auto newTunnel = tunnels.CreateOutboundTunnel (config);
newTunnel->SetTunnelPool (shared_from_this ()); newTunnel->SetTunnelPool (shared_from_this ());
if (newTunnel->IsEstablished ()) // zero hops if (newTunnel->IsEstablished ()) // zero hops
TunnelCreated (newTunnel); TunnelCreated (newTunnel);

Loading…
Cancel
Save