diff options
-rw-r--r-- | controller/FileDB.cpp | 11 | ||||
-rw-r--r-- | node/IncomingPacket.cpp | 6 |
2 files changed, 9 insertions, 8 deletions
diff --git a/controller/FileDB.cpp b/controller/FileDB.cpp index 69573306..eb2ec00d 100644 --- a/controller/FileDB.cpp +++ b/controller/FileDB.cpp @@ -86,25 +86,26 @@ FileDB::FileDB(EmbeddedNetworkController *const nc,const Identity &myId,const ch FILE *f = fopen(p,"wb"); if (f) { fprintf(f,"{"); - char *memberPrefix = ""; + const char *memberPrefix = ""; for(auto m=nw->second.begin();m!=nw->second.end();++m) { fprintf(f,"%s\"%.10llx\":{" ZT_EOL_S,memberPrefix,(unsigned long long)m->first); memberPrefix = ","; InetAddress lastAddr; - char *timestampPrefix = " "; + const char *timestampPrefix = " "; int cnt = 0; - for(auto ts=m->second.rbegin();ts!=m->second.rend();++ts) { + for(auto ts=m->second.rbegin();ts!=m->second.rend();) { if (cnt < 25) { if (lastAddr != ts->second) { lastAddr = ts->second; fprintf(f,"%s\"%lld\":\"%s\"" ZT_EOL_S,timestampPrefix,(long long)ts->first,ts->second.toString(atmp)); timestampPrefix = ","; ++cnt; + ++ts; } else { - m->second.erase(ts.base()); // erase previous entries for same IP/port + ts = std::map<int64_t,InetAddress>::reverse_iterator(m->second.erase(std::next(ts).base())); } } else { - m->second.erase(ts.base()); // erase entries beyond the 25 max written to log + ts = std::map<int64_t,InetAddress>::reverse_iterator(m->second.erase(std::next(ts).base())); } } fprintf(f,"}"); diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 7a1193c0..b774f1df 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -502,8 +502,8 @@ bool IncomingPacket::_doOK(const RuntimeEnvironment *RR,void *tPtr,const SharedP } } - if (!hops() && (RR->node->getMultipathMode() != ZT_MULTIPATH_NONE)) { - _path->updateLatency((unsigned int)latency, RR->node->now()); + if (!hops()) { + _path->updateLatency((unsigned int)latency,RR->node->now()); } peer->setRemoteVersion(vProto,vMajor,vMinor,vRevision); @@ -614,7 +614,7 @@ bool IncomingPacket::_doRENDEZVOUS(const RuntimeEnvironment *RR,void *tPtr,const const unsigned int port = at<uint16_t>(ZT_PROTO_VERB_RENDEZVOUS_IDX_PORT); const unsigned int addrlen = (*this)[ZT_PROTO_VERB_RENDEZVOUS_IDX_ADDRLEN]; if ((port > 0)&&((addrlen == 4)||(addrlen == 16))) { - const InetAddress atAddr(field(ZT_PROTO_VERB_RENDEZVOUS_IDX_ADDRESS,addrlen),addrlen,port); + InetAddress atAddr(field(ZT_PROTO_VERB_RENDEZVOUS_IDX_ADDRESS,addrlen),addrlen,port); if (RR->node->shouldUsePathForZeroTierTraffic(tPtr,with,_path->localSocket(),atAddr)) { const uint64_t junk = RR->node->prng(); RR->node->putPacket(tPtr,_path->localSocket(),atAddr,&junk,4,2); // send low-TTL junk packet to 'open' local NAT(s) and stateful firewalls |