mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2024-12-21 13:57:49 +00:00
Yay... now everything compiles! Getting close to testing on this. Still have not added backward compatibility support for relaying of multicasts to 0.9.X clients yet but that will be easy. Will test with heterogenous 1.0.0 clients only first.
This commit is contained in:
parent
ea6124dd2f
commit
ae082c3cb8
@ -163,6 +163,16 @@ public:
|
||||
return _myMulticastGroups;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param mg Multicast group
|
||||
* @return True if this group is among those to which I am subscribed
|
||||
*/
|
||||
inline bool wantMulticastGroup(const MulticastGroup &mg) const
|
||||
{
|
||||
Mutex::Lock _l(_lock);
|
||||
return (_myMulticastGroups.count(mg) > 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set or update this network's configuration
|
||||
*
|
||||
|
@ -383,11 +383,11 @@ Node::ReasonForTermination Node::run()
|
||||
RR->http = new HttpClient();
|
||||
RR->antiRec = new AntiRecursion();
|
||||
RR->mc = new Multicaster();
|
||||
RR->sw = new Switch(_r);
|
||||
RR->sm = new SocketManager(impl->udpPort,impl->tcpPort,&_CBztTraffic,_r);
|
||||
RR->sw = new Switch(RR);
|
||||
RR->sm = new SocketManager(impl->udpPort,impl->tcpPort,&_CBztTraffic,RR);
|
||||
RR->topology = new Topology(RR,Utils::fileExists((RR->homePath + ZT_PATH_SEPARATOR_S + "iddb.d").c_str()));
|
||||
try {
|
||||
RR->nc = new NodeConfig(_r);
|
||||
RR->nc = new NodeConfig(RR);
|
||||
} catch (std::exception &exc) {
|
||||
return impl->terminateBecause(Node::NODE_UNRECOVERABLE_ERROR,"unable to initialize IPC socket: is ZeroTier One already running?");
|
||||
}
|
||||
@ -395,7 +395,7 @@ Node::ReasonForTermination Node::run()
|
||||
|
||||
#ifdef ZT_AUTO_UPDATE
|
||||
if (ZT_DEFAULTS.updateLatestNfoURL.length()) {
|
||||
RR->updater = new SoftwareUpdater(_r);
|
||||
RR->updater = new SoftwareUpdater(RR);
|
||||
RR->updater->cleanOldUpdates(); // clean out updates.d on startup
|
||||
} else {
|
||||
LOG("WARNING: unable to enable software updates: latest .nfo URL from ZT_DEFAULTS is empty (does this platform actually support software updates?)");
|
||||
@ -443,7 +443,7 @@ Node::ReasonForTermination Node::run()
|
||||
std::string netconfServicePath(RR->homePath + ZT_PATH_SEPARATOR_S + "services.d" + ZT_PATH_SEPARATOR_S + "netconf.service");
|
||||
if (Utils::fileExists(netconfServicePath.c_str())) {
|
||||
LOG("netconf.d/netconf.service appears to exist, starting...");
|
||||
RR->netconfService = new Service(RR,"netconf",netconfServicePath.c_str(),&_netconfServiceMessageHandler,_r);
|
||||
RR->netconfService = new Service(RR,"netconf",netconfServicePath.c_str(),&_netconfServiceMessageHandler,RR);
|
||||
Dictionary initMessage;
|
||||
initMessage["type"] = "netconf-init";
|
||||
initMessage["netconfId"] = RR->identity.toString(true);
|
||||
@ -570,7 +570,7 @@ Node::ReasonForTermination Node::run()
|
||||
try {
|
||||
std::vector< SharedPtr<Network> > networks(RR->nc->networks());
|
||||
for(std::vector< SharedPtr<Network> >::const_iterator nw(networks.begin());nw!=networks.end();++nw)
|
||||
(*nw)->updateMulticastGroups());
|
||||
(*nw)->updateMulticastGroups();
|
||||
} catch (std::exception &exc) {
|
||||
LOG("unexpected exception announcing multicast groups: %s",exc.what());
|
||||
} catch ( ... ) {
|
||||
@ -631,7 +631,7 @@ Node::ReasonForTermination Node::run()
|
||||
lastRootTopologyFetch = now;
|
||||
if (!impl->disableRootTopologyUpdates) {
|
||||
TRACE("fetching root topology from %s",ZT_DEFAULTS.rootTopologyUpdateURL.c_str());
|
||||
RR->http->GET(ZT_DEFAULTS.rootTopologyUpdateURL,HttpClient::NO_HEADERS,60,&_cbHandleGetRootTopology,_r);
|
||||
RR->http->GET(ZT_DEFAULTS.rootTopologyUpdateURL,HttpClient::NO_HEADERS,60,&_cbHandleGetRootTopology,RR);
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,7 +715,7 @@ bool Node::initialized()
|
||||
{
|
||||
_NodeImpl *impl = (_NodeImpl *)_impl;
|
||||
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
|
||||
return ((_r)&&(RR->initialized));
|
||||
return ((RR)&&(RR->initialized));
|
||||
}
|
||||
|
||||
uint64_t Node::address()
|
||||
@ -723,7 +723,7 @@ uint64_t Node::address()
|
||||
{
|
||||
_NodeImpl *impl = (_NodeImpl *)_impl;
|
||||
RuntimeEnvironment *RR = (RuntimeEnvironment *)&(impl->renv);
|
||||
if ((!_r)||(!RR->initialized))
|
||||
if ((!RR)||(!RR->initialized))
|
||||
return 0;
|
||||
return RR->identity.address().toInt();
|
||||
}
|
||||
|
@ -52,7 +52,7 @@
|
||||
namespace ZeroTier {
|
||||
|
||||
NodeConfig::NodeConfig(const RuntimeEnvironment *renv) :
|
||||
_r(renv)
|
||||
RR(renv)
|
||||
{
|
||||
{
|
||||
Mutex::Lock _l(_localConfig_m);
|
||||
|
@ -52,7 +52,7 @@
|
||||
namespace ZeroTier {
|
||||
|
||||
Service::Service(const RuntimeEnvironment *renv,const char *name,const char *path,void (*handler)(void *,Service &,const Dictionary &),void *arg) :
|
||||
_r(renv),
|
||||
RR(renv),
|
||||
_path(path),
|
||||
_name(name),
|
||||
_arg(arg),
|
||||
|
@ -55,7 +55,7 @@
|
||||
namespace ZeroTier {
|
||||
|
||||
SoftwareUpdater::SoftwareUpdater(const RuntimeEnvironment *renv) :
|
||||
_r(renv),
|
||||
RR(renv),
|
||||
_myVersion(packVersion(ZEROTIER_ONE_VERSION_MAJOR,ZEROTIER_ONE_VERSION_MINOR,ZEROTIER_ONE_VERSION_REVISION)),
|
||||
_lastUpdateAttempt(0),
|
||||
_status(UPDATE_STATUS_IDLE),
|
||||
@ -158,7 +158,7 @@ bool SoftwareUpdater::validateUpdate(
|
||||
void SoftwareUpdater::_cbHandleGetLatestVersionInfo(void *arg,int code,const std::string &url,const std::string &body)
|
||||
{
|
||||
SoftwareUpdater *upd = (SoftwareUpdater *)arg;
|
||||
const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->_r;
|
||||
const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->RR;
|
||||
Mutex::Lock _l(upd->_lock);
|
||||
|
||||
if ((upd->_die)||(upd->_status != UPDATE_STATUS_GETTING_NFO)) {
|
||||
@ -213,7 +213,7 @@ void SoftwareUpdater::_cbHandleGetLatestVersionInfo(void *arg,int code,const std
|
||||
void SoftwareUpdater::_cbHandleGetLatestVersionBinary(void *arg,int code,const std::string &url,const std::string &body)
|
||||
{
|
||||
SoftwareUpdater *upd = (SoftwareUpdater *)arg;
|
||||
const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->_r;
|
||||
const RuntimeEnvironment *RR = (const RuntimeEnvironment *)upd->RR;
|
||||
Mutex::Lock _l(upd->_lock);
|
||||
|
||||
if (!validateUpdate(body.data(),(unsigned int)body.length(),upd->_signedBy,upd->_signature)) {
|
||||
|
@ -55,7 +55,7 @@
|
||||
namespace ZeroTier {
|
||||
|
||||
Switch::Switch(const RuntimeEnvironment *renv) :
|
||||
_r(renv),
|
||||
RR(renv),
|
||||
_lastBeacon(0)
|
||||
{
|
||||
}
|
||||
@ -150,7 +150,17 @@ void Switch::onLocalEthernet(const SharedPtr<Network> &network,const MAC &from,c
|
||||
|
||||
TRACE("%s: MULTICAST %s -> %s %s %d",network->tapDeviceName().c_str(),from.toString().c_str(),mg.toString().c_str(),etherTypeName(etherType),(int)data.size());
|
||||
|
||||
network->sendMulticast(mg,from,etherType,data.data(),data.size());
|
||||
RR->mc->send(
|
||||
RR,
|
||||
((!nconf->isPublic())&&(nconf->com())) ? &(nconf->com()) : (const CertificateOfMembership *)0,
|
||||
network->wantMulticastGroup(mg) ? nconf->multicastLimit() : 0,
|
||||
now,
|
||||
network->id(),
|
||||
mg,
|
||||
from,
|
||||
etherType,
|
||||
data.data(),
|
||||
data.size());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -431,8 +441,8 @@ void Switch::doAnythingWaitingForPeer(const SharedPtr<Peer> &peer)
|
||||
|
||||
{ // finish processing any packets waiting on peer's public key / identity
|
||||
Mutex::Lock _l(_rxQueue_m);
|
||||
for(std::list< SharedPtr<IncomingPacket> >::iterator rxi(_rxQueue.begin());rxi!=_rxQueue.end();) {
|
||||
if ((*rxi)->tryDecode(_r))
|
||||
for(std::vector< SharedPtr<IncomingPacket> >::iterator rxi(_rxQueue.begin());rxi!=_rxQueue.end();) {
|
||||
if ((*rxi)->tryDecode(RR))
|
||||
_rxQueue.erase(rxi++);
|
||||
else ++rxi;
|
||||
}
|
||||
@ -518,7 +528,7 @@ unsigned long Switch::doTimerTasks()
|
||||
|
||||
{
|
||||
Mutex::Lock _l(_rxQueue_m);
|
||||
for(std::list< SharedPtr<IncomingPacket> >::iterator i(_rxQueue.begin());i!=_rxQueue.end();) {
|
||||
for(std::vector< SharedPtr<IncomingPacket> >::iterator i(_rxQueue.begin());i!=_rxQueue.end();) {
|
||||
if ((now - (*i)->receiveTime()) > ZT_RECEIVE_QUEUE_TIMEOUT) {
|
||||
TRACE("RX %s -> %s timed out",(*i)->source().toString().c_str(),(*i)->destination().toString().c_str());
|
||||
_rxQueue.erase(i++);
|
||||
@ -617,7 +627,7 @@ void Switch::_handleRemotePacketFragment(const SharedPtr<Socket> &fromSock,const
|
||||
packet->append(dqe->second.frags[f - 1].payload(),dqe->second.frags[f - 1].payloadLength());
|
||||
_defragQueue.erase(dqe);
|
||||
|
||||
if (!packet->tryDecode(_r)) {
|
||||
if (!packet->tryDecode(RR)) {
|
||||
Mutex::Lock _l(_rxQueue_m);
|
||||
_rxQueue.push_back(packet);
|
||||
}
|
||||
@ -684,7 +694,7 @@ void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const Ine
|
||||
packet->append(dqe->second.frags[f - 1].payload(),dqe->second.frags[f - 1].payloadLength());
|
||||
_defragQueue.erase(dqe);
|
||||
|
||||
if (!packet->tryDecode(_r)) {
|
||||
if (!packet->tryDecode(RR)) {
|
||||
Mutex::Lock _l(_rxQueue_m);
|
||||
_rxQueue.push_back(packet);
|
||||
}
|
||||
@ -695,7 +705,7 @@ void Switch::_handleRemotePacketHead(const SharedPtr<Socket> &fromSock,const Ine
|
||||
} // else this is a duplicate head, ignore
|
||||
} else {
|
||||
// Packet is unfragmented, so just process it
|
||||
if (!packet->tryDecode(_r)) {
|
||||
if (!packet->tryDecode(RR)) {
|
||||
Mutex::Lock _l(_rxQueue_m);
|
||||
_rxQueue.push_back(packet);
|
||||
}
|
||||
|
@ -216,7 +216,7 @@ private:
|
||||
const Packet &packet,
|
||||
bool encrypt);
|
||||
|
||||
const RuntimeEnvironment *const _r;
|
||||
const RuntimeEnvironment *const RR;
|
||||
volatile uint64_t _lastBeacon;
|
||||
|
||||
// Outsanding WHOIS requests and how many retries they've undergone
|
||||
|
Loading…
Reference in New Issue
Block a user