summaryrefslogtreecommitdiff
path: root/node/Node.cpp
diff options
context:
space:
mode:
authorAdam Ierymenko <adam.ierymenko@gmail.com>2013-10-17 05:37:01 -0400
committerAdam Ierymenko <adam.ierymenko@gmail.com>2013-10-17 05:37:01 -0400
commit7e7e28f5f7d53df8f4897b243088d2f664651ae6 (patch)
treecfd11f8f81409e87c0a73ef6b8e422faa8ab2962 /node/Node.cpp
parent46f868bd4fb2fd7b0816ded98974935aacddf5e6 (diff)
downloadinfinitytier-7e7e28f5f7d53df8f4897b243088d2f664651ae6.tar.gz
infinitytier-7e7e28f5f7d53df8f4897b243088d2f664651ae6.zip
Add support for pushing network config refresh hints from a MEMORY queue table. That ways it will be possible for network changes to take effect almost immediately across all active peers.
Diffstat (limited to 'node/Node.cpp')
-rw-r--r--node/Node.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/node/Node.cpp b/node/Node.cpp
index fe95701a..71d8b097 100644
--- a/node/Node.cpp
+++ b/node/Node.cpp
@@ -269,6 +269,34 @@ static void _netconfServiceMessageHandler(void *renv,Service &svc,const Dictiona
}
}
}
+ } else if (type == "netconf-push") {
+ if (msg.contains("to")) {
+ Dictionary to(msg.get("to")); // key: peer address, value: comma-delimited network list
+ for(Dictionary::iterator t(to.begin());t!=to.end();++t) {
+ Address ztaddr(t->first);
+ if (ztaddr) {
+ Packet outp(ztaddr,_r->identity.address(),Packet::VERB_NETWORK_CONFIG_REFRESH);
+
+ char *saveptr = (char *)0;
+ // Note: this loop trashes t->second, which is quasi-legal C++ but
+ // shouldn't break anything as long as we don't try to use 'to'
+ // for anything interesting after doing this.
+ for(char *p=Utils::stok(const_cast<char *>(t->second.c_str()),",",&saveptr);(p);p=Utils::stok((char *)0,",",&saveptr)) {
+ uint64_t nwid = Utils::hexStrToU64(p);
+ if (nwid) {
+ if ((outp.size() + sizeof(uint64_t)) >= ZT_UDP_DEFAULT_PAYLOAD_MTU) {
+ _r->sw->send(outp,true);
+ outp.reset(ztaddr,_r->identity.address(),Packet::VERB_NETWORK_CONFIG_REFRESH);
+ }
+ outp.append(nwid);
+ }
+ }
+
+ if (outp.payloadLength())
+ _r->sw->send(outp,true);
+ }
+ }
+ }
}
} catch (std::exception &exc) {
LOG("unexpected exception parsing response from netconf service: %s",exc.what());