TRACE compile fixes, other fixes, and it basically works! It says HELLO.

This commit is contained in:
Adam Ierymenko 2015-04-09 20:54:00 -07:00
commit 068d311ecc
12 changed files with 140 additions and 33 deletions

View file

@ -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;
}

View file

@ -353,6 +353,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
*/

View file

@ -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);

View file

@ -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,