Browse Source

fixed broken re-created tunnels

pull/93/head
orignal 10 years ago
parent
commit
6e70c04516
  1. 19
      TunnelConfig.h

19
TunnelConfig.h

@ -89,7 +89,7 @@ namespace tunnel
TunnelConfig (std::vector<const i2p::data::RouterInfo *> peers, TunnelConfig (std::vector<const i2p::data::RouterInfo *> peers,
const TunnelConfig * replyTunnelConfig = nullptr) // replyTunnelConfig=0 means inbound const TunnelConfig * replyTunnelConfig = nullptr) // replyTunnelConfig=nullptr means inbound
{ {
TunnelHopConfig * prev = nullptr; TunnelHopConfig * prev = nullptr;
for (auto it: peers) for (auto it: peers)
@ -195,23 +195,14 @@ namespace tunnel
TunnelConfig * Clone (const TunnelConfig * replyTunnelConfig = nullptr) const TunnelConfig * Clone (const TunnelConfig * replyTunnelConfig = nullptr) const
{ {
TunnelConfig * newConfig = new TunnelConfig (); std::vector<const i2p::data::RouterInfo *> peers;
TunnelHopConfig * hop = m_FirstHop, * prev = nullptr; TunnelHopConfig * hop = m_FirstHop;
while (hop) while (hop)
{ {
TunnelHopConfig * newHop = new TunnelHopConfig (hop->router); peers.push_back (hop->router);
newHop->SetPrev (prev);
newHop->SetNextRouter (hop->nextRouter);
newHop->isGateway = hop->isGateway;
newHop->isEndpoint = hop->isEndpoint;
prev = newHop;
if (!newConfig->m_FirstHop) newConfig->m_FirstHop = newHop;
hop = hop->next; hop = hop->next;
} }
newConfig->m_LastHop = prev; return new TunnelConfig (peers, replyTunnelConfig);
if (replyTunnelConfig && newConfig->m_LastHop)
newConfig->m_LastHop->SetReplyHop (replyTunnelConfig->GetFirstHop ());
return newConfig;
} }
private: private:

Loading…
Cancel
Save