From f13493edb2aae228ddbe70cc2f0609c541faf2d7 Mon Sep 17 00:00:00 2001 From: Adam Ierymenko Date: Mon, 31 Mar 2014 22:23:55 -0700 Subject: Oops... turns out we need to differentiate incoming from outgoing TCP and indeed learn incoming TCP paths. Otherwise the recipient of a TCP connection does not know to reply via TCP! Heh. --- node/Switch.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'node/Switch.cpp') diff --git a/node/Switch.cpp b/node/Switch.cpp index 0e58c744..2ee3a4a0 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -214,7 +214,7 @@ void Switch::sendHELLO(const Address &dest) send(outp,false); } -bool Switch::sendHELLO(const SharedPtr &fromSock,const SharedPtr &dest,const InetAddress &remoteAddr) +bool Switch::sendHELLO(const SharedPtr &dest,const Path &path) { uint64_t now = Utils::now(); Packet outp(dest->address(),_r->identity.address(),Packet::VERB_HELLO); @@ -225,10 +225,10 @@ bool Switch::sendHELLO(const SharedPtr &fromSock,const SharedPtr & outp.append(now); _r->identity.serialize(outp,false); outp.armor(dest->key(),false); - return fromSock->send(remoteAddr,outp.data(),outp.size()); + return _r->sm->send(path.address(),path.tcp(),path.type() == Path::PATH_TYPE_TCP_OUT,outp.data(),outp.size()); } -bool Switch::sendHELLO(const SharedPtr &dest,const InetAddress &remoteAddr,bool tcp) +bool Switch::sendHELLO(const SharedPtr &dest,const InetAddress &destUdp) { uint64_t now = Utils::now(); Packet outp(dest->address(),_r->identity.address(),Packet::VERB_HELLO); @@ -239,7 +239,7 @@ bool Switch::sendHELLO(const SharedPtr &dest,const InetAddress &remoteAddr outp.append(now); _r->identity.serialize(outp,false); outp.armor(dest->key(),false); - return _r->sm->send(remoteAddr,tcp,outp.data(),outp.size()); + return _r->sm->send(deskUdp,false,false,outp.data(),outp.size()); } bool Switch::unite(const Address &p1,const Address &p2,bool force) @@ -354,7 +354,7 @@ unsigned long Switch::doTimerTasks() for(std::list::iterator qi(_contactQueue.begin());qi!=_contactQueue.end();) { if (now >= qi->fireAtTime) { TRACE("sending NAT-T HELLO to %s(%s)",qi->peer->address().toString().c_str(),qi->inaddr.toString().c_str()); - sendHELLO(qi->peer,qi->inaddr,false); + sendHELLO(qi->peer,qi->inaddr); _contactQueue.erase(qi++); } else { nextDelay = std::min(nextDelay,(unsigned long)(qi->fireAtTime - now)); -- cgit v1.2.3