diff options
Diffstat (limited to 'node')
-rw-r--r-- | node/IncomingPacket.cpp | 4 | ||||
-rw-r--r-- | node/InetAddress.hpp | 13 | ||||
-rw-r--r-- | node/Node.cpp | 11 | ||||
-rw-r--r-- | node/Switch.cpp | 6 |
4 files changed, 27 insertions, 7 deletions
diff --git a/node/IncomingPacket.cpp b/node/IncomingPacket.cpp index 690c2c9d..aadef3c2 100644 --- a/node/IncomingPacket.cpp +++ b/node/IncomingPacket.cpp @@ -304,9 +304,9 @@ bool IncomingPacket::_doHELLO(const RuntimeEnvironment *RR) outp.armor(peer->key(),true); RR->node->putPacket(_remoteAddress,outp.data(),outp.size(),_linkDesperation); } catch (std::exception &ex) { - TRACE("dropped HELLO from %s(%s): %s",id.address().toString().c_str(),_remoteAddress.toString().c_str(),ex.what()); + TRACE("dropped HELLO from %s(%s): %s",source().toString().c_str(),_remoteAddress.toString().c_str(),ex.what()); } catch ( ... ) { - TRACE("dropped HELLO from %s(%s): unexpected exception",id.address().toString().c_str(),_remoteAddress.toString().c_str()); + TRACE("dropped HELLO from %s(%s): unexpected exception",source().toString().c_str(),_remoteAddress.toString().c_str()); } return true; } diff --git a/node/InetAddress.hpp b/node/InetAddress.hpp index 43fcc333..5e4dbfd8 100644 --- a/node/InetAddress.hpp +++ b/node/InetAddress.hpp @@ -354,6 +354,19 @@ struct InetAddress : public sockaddr_storage } /** + * @param a InetAddress to compare again + * @return True if only IP portions are equal (false for non-IP or null addresses) + */ + inline bool ipsEqual(const InetAddress &a) const + { + switch(ss_family) { + case AF_INET: return (reinterpret_cast<const struct sockaddr_in *>(this)->sin_addr.s_addr == reinterpret_cast<const struct sockaddr_in *>(&a)->sin_addr.s_addr); + case AF_INET6: return (memcmp(reinterpret_cast<const struct sockaddr_in6 *>(this)->sin6_addr.s6_addr,reinterpret_cast<const struct sockaddr_in6 *>(&a)->sin6_addr.s6_addr,16) == 0); + } + return false; + } + + /** * Set to null/zero */ inline void zero() throw() { memset(this,0,sizeof(InetAddress)); } diff --git a/node/Node.cpp b/node/Node.cpp index e6f73879..0192c49a 100644 --- a/node/Node.cpp +++ b/node/Node.cpp @@ -82,6 +82,7 @@ Node::Node( std::string idtmp(dataStoreGet("identity.secret")); if ((!idtmp.length())||(!RR->identity.fromString(idtmp))||(!RR->identity.hasPrivate())) { + TRACE("identity.secret not found, generating..."); RR->identity.generate(); idtmp = RR->identity.toString(true); if (!dataStorePut("identity.secret",idtmp,true)) { @@ -444,10 +445,16 @@ void Node::postTrace(const char *module,unsigned int line,const char *fmt,...) #ifdef __WINDOWS__ ctime_s(tmp3,sizeof(tmp3),&now); - const char *nowstr = tmp3; + char *nowstr = tmp3; #else - const char *nowstr = ctime_r(&now,tmp3); + time_t now = (time_t)(_now / 1000ULL); + char *nowstr = ctime_r(&now,tmp3); #endif + unsigned long nowstrlen = strlen(nowstr); + if (nowstr[nowstrlen-1] == '\n') + nowstr[--nowstrlen] = (char)0; + if (nowstr[nowstrlen-1] == '\r') + nowstr[--nowstrlen] = (char)0; va_start(ap,fmt); vsnprintf(tmp2,sizeof(tmp2),fmt,ap); diff --git a/node/Switch.cpp b/node/Switch.cpp index a73c354e..caeb3e3a 100644 --- a/node/Switch.cpp +++ b/node/Switch.cpp @@ -92,7 +92,7 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c * still happen because Windows likes to send broadcasts over interfaces that have little * to do with their intended target audience. :P */ if (!RR->antiRec->checkEthernetFrame(data,len)) { - TRACE("%.16llx: rejected recursively addressed ZeroTier packet by tail match (type %s, length: %u)",network->id(),etherTypeName(etherType),data.size()); + TRACE("%.16llx: rejected recursively addressed ZeroTier packet by tail match (type %s, length: %u)",network->id(),etherTypeName(etherType),len); return; } @@ -149,11 +149,11 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c // Check multicast/broadcast bandwidth quotas and reject if quota exceeded if (!network->updateAndCheckMulticastBalance(mg,len)) { - TRACE("%.16llx: didn't multicast %d bytes, quota exceeded for multicast group %s",network->id(),(int)data.size(),mg.toString().c_str()); + TRACE("%.16llx: didn't multicast %u bytes, quota exceeded for multicast group %s",network->id(),len,mg.toString().c_str()); return; } - TRACE("%.16llx: MULTICAST %s -> %s %s %d",network->id(),from.toString().c_str(),mg.toString().c_str(),etherTypeName(etherType),(int)data.size()); + //TRACE("%.16llx: MULTICAST %s -> %s %s %u",network->id(),from.toString().c_str(),mg.toString().c_str(),etherTypeName(etherType),len); RR->mc->send( ((!nconf->isPublic())&&(nconf->com())) ? &(nconf->com()) : (const CertificateOfMembership *)0, |