summaryrefslogtreecommitdiff
path: root/node/Switch.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-12-24 10:39:29 -0800
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-12-24 10:39:29 -0800
commit92969b442625007823dd0accf7ffec295f1ea4b1 (patch)
treea792846c305540c4d26d84fb29a2024bb1ccaf0b /node/Switch.cpp
parent026442f28fc6da30ce16b44cee94553a7730b2ac (diff)
downloadinfinitytier-92969b442625007823dd0accf7ffec295f1ea4b1.tar.gz
infinitytier-92969b442625007823dd0accf7ffec295f1ea4b1.zip
Fix for GitHub issue #20 (untested)
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r--node/Switch.cpp18
1 files changed, 16 insertions, 2 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp
index f0641e74..a46746e7 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -219,7 +219,11 @@ bool Switch::sendHELLO(const SharedPtr<Peer> &dest,Demarc::Port localPort,const
outp.append(now);
_r->identity.serialize(outp,false);
outp.armor(dest->key(),false);
- return _r->demarc->send(localPort,remoteAddr,outp.data(),outp.size(),-1);
+
+ if (_r->demarc->send(localPort,remoteAddr,outp.data(),outp.size(),-1)) {
+ dest->expectResponseTo(outp.packetId(),Packet::VERB_HELLO,localPort,now);
+ return true;
+ } else return false;
}
bool Switch::unite(const Address &p1,const Address &p2,bool force)
@@ -696,7 +700,8 @@ bool Switch::_trySend(const Packet &packet,bool encrypt)
tmp.armor(peer->key(),encrypt);
- if (via->send(_r,tmp.data(),chunkSize,now)) {
+ Demarc::Port localPort;
+ if ((localPort = via->send(_r,tmp.data(),chunkSize,now))) {
if (chunkSize < tmp.size()) {
// Too big for one bite, fragment the rest
unsigned int fragStart = chunkSize;
@@ -716,6 +721,15 @@ bool Switch::_trySend(const Packet &packet,bool encrypt)
remaining -= chunkSize;
}
}
+
+ switch(packet.verb()) {
+ case Packet::VERB_HELLO:
+ peer->expectResponseTo(packet.packetId(),Packet::VERB_HELLO,localPort,now);
+ break;
+ default:
+ break;
+ }
+
return true;
}
return false;