summaryrefslogtreecommitdiff
path: root/node/Switch.cpp
diff options
context:
space:
mode:
authorGrant Limberg <glimberg@gmail.com>2015-07-16 18:09:57 -0700
committerGrant Limberg <glimberg@gmail.com>2015-07-16 18:09:57 -0700
commit1e8ead441c90b731573d7949152643e0082bdb2e (patch)
tree80f15238fc0b3543f880bcd03564fe6e2ee95731 /node/Switch.cpp
parente45475c5b5bcee4fb88e797a50eb38b6ad3d6923 (diff)
parent0db7c94c9004ac488b6163905d80f7515141d9c6 (diff)
downloadinfinitytier-1e8ead441c90b731573d7949152643e0082bdb2e.tar.gz
infinitytier-1e8ead441c90b731573d7949152643e0082bdb2e.zip
Merge branch 'adamierymenko-dev' into android-jni
Diffstat (limited to 'node/Switch.cpp')
-rw-r--r--node/Switch.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/node/Switch.cpp b/node/Switch.cpp
index 4fd5d769..cf4fe249 100644
--- a/node/Switch.cpp
+++ b/node/Switch.cpp
@@ -65,7 +65,8 @@ static const char *etherTypeName(const unsigned int etherType)
#endif // ZT_TRACE
Switch::Switch(const RuntimeEnvironment *renv) :
- RR(renv)
+ RR(renv),
+ _lastBeaconResponse(0)
{
}
@@ -76,7 +77,25 @@ Switch::~Switch()
void Switch::onRemotePacket(const InetAddress &fromAddr,const void *data,unsigned int len)
{
try {
- if (len > ZT_PROTO_MIN_FRAGMENT_LENGTH) {
+ if (len == 13) {
+ /* LEGACY: before VERB_PUSH_DIRECT_PATHS, peers used broadcast
+ * announcements on the LAN to solve the 'same network problem.' We
+ * no longer send these, but we'll listen for them for a while to
+ * locate peers with versions <1.0.4. */
+ Address beaconAddr(reinterpret_cast<const char *>(data) + 8,5);
+ if (beaconAddr == RR->identity.address())
+ return;
+ SharedPtr<Peer> peer(RR->topology->getPeer(beaconAddr));
+ if (peer) { // we'll only respond to beacons from known peers
+ const uint64_t now = RR->node->now();
+ if ((now - _lastBeaconResponse) >= 2500) { // limit rate of responses
+ _lastBeaconResponse = now;
+ Packet outp(peer->address(),RR->identity.address(),Packet::VERB_NOP);
+ outp.armor(peer->key(),false);
+ RR->node->putPacket(fromAddr,outp.data(),outp.size());
+ }
+ }
+ } else if (len > ZT_PROTO_MIN_FRAGMENT_LENGTH) {
if (((const unsigned char *)data)[ZT_PACKET_FRAGMENT_IDX_FRAGMENT_INDICATOR] == ZT_PACKET_FRAGMENT_INDICATOR) {
_handleRemotePacketFragment(fromAddr,data,len);
} else if (len >= ZT_PROTO_MIN_PACKET_LENGTH) {