mirror of
https://github.com/zerotier/ZeroTierOne.git
synced 2025-01-31 00:23:58 +00:00
Put CONFIG_REFRESH back.
This commit is contained in:
parent
4d498b3765
commit
774c7e0ea5
@ -102,6 +102,7 @@ bool IncomingPacket::tryDecode(const RuntimeEnvironment *RR)
|
|||||||
case Packet::VERB_MULTICAST_LIKE: return _doMULTICAST_LIKE(RR,peer);
|
case Packet::VERB_MULTICAST_LIKE: return _doMULTICAST_LIKE(RR,peer);
|
||||||
case Packet::VERB_NETWORK_CREDENTIALS: return _doNETWORK_CREDENTIALS(RR,peer);
|
case Packet::VERB_NETWORK_CREDENTIALS: return _doNETWORK_CREDENTIALS(RR,peer);
|
||||||
case Packet::VERB_NETWORK_CONFIG_REQUEST: return _doNETWORK_CONFIG_REQUEST(RR,peer);
|
case Packet::VERB_NETWORK_CONFIG_REQUEST: return _doNETWORK_CONFIG_REQUEST(RR,peer);
|
||||||
|
case Packet::VERB_NETWORK_CONFIG_REFRESH: return _doNETWORK_CONFIG_REFRESH(RR,peer);
|
||||||
case Packet::VERB_MULTICAST_GATHER: return _doMULTICAST_GATHER(RR,peer);
|
case Packet::VERB_MULTICAST_GATHER: return _doMULTICAST_GATHER(RR,peer);
|
||||||
case Packet::VERB_MULTICAST_FRAME: return _doMULTICAST_FRAME(RR,peer);
|
case Packet::VERB_MULTICAST_FRAME: return _doMULTICAST_FRAME(RR,peer);
|
||||||
case Packet::VERB_PUSH_DIRECT_PATHS: return _doPUSH_DIRECT_PATHS(RR,peer);
|
case Packet::VERB_PUSH_DIRECT_PATHS: return _doPUSH_DIRECT_PATHS(RR,peer);
|
||||||
@ -724,67 +725,70 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
|
|||||||
peer->received(_localAddress,_remoteAddress,h,requestPacketId,Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP);
|
peer->received(_localAddress,_remoteAddress,h,requestPacketId,Packet::VERB_NETWORK_CONFIG_REQUEST,0,Packet::VERB_NOP);
|
||||||
|
|
||||||
if (RR->localNetworkController) {
|
if (RR->localNetworkController) {
|
||||||
NetworkConfig netconf;
|
NetworkConfig *netconf = new NetworkConfig();
|
||||||
switch(RR->localNetworkController->doNetworkConfigRequest((h > 0) ? InetAddress() : _remoteAddress,RR->identity,peer->identity(),nwid,metaData,netconf)) {
|
try {
|
||||||
|
switch(RR->localNetworkController->doNetworkConfigRequest((h > 0) ? InetAddress() : _remoteAddress,RR->identity,peer->identity(),nwid,metaData,*netconf)) {
|
||||||
|
|
||||||
case NetworkController::NETCONF_QUERY_OK: {
|
case NetworkController::NETCONF_QUERY_OK: {
|
||||||
Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> *dconf = new Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY>();
|
Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> *dconf = new Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY>();
|
||||||
try {
|
try {
|
||||||
if (netconf.toDictionary(*dconf,metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION,0) < 6)) {
|
if (netconf->toDictionary(*dconf,metaData.getUI(ZT_NETWORKCONFIG_REQUEST_METADATA_KEY_VERSION,0) < 6)) {
|
||||||
const unsigned int totalSize = dconf->sizeBytes();
|
const unsigned int totalSize = dconf->sizeBytes();
|
||||||
unsigned int chunkPtr = 0;
|
unsigned int chunkIndex = 0;
|
||||||
while (chunkPtr < totalSize) {
|
while (chunkIndex < totalSize) {
|
||||||
const unsigned int chunkLen = std::min(totalSize - chunkPtr,(unsigned int)(ZT_PROTO_MAX_PACKET_LENGTH - (ZT_PROTO_MIN_PACKET_LENGTH + 32)));
|
const unsigned int chunkLen = std::min(totalSize - chunkIndex,(unsigned int)(ZT_PROTO_MAX_PACKET_LENGTH - (ZT_PROTO_MIN_PACKET_LENGTH + 32)));
|
||||||
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_OK);
|
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_OK);
|
||||||
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
||||||
outp.append(requestPacketId);
|
outp.append(requestPacketId);
|
||||||
outp.append(nwid);
|
outp.append(nwid);
|
||||||
outp.append((uint16_t)chunkLen);
|
outp.append((uint16_t)chunkLen);
|
||||||
outp.append((const void *)(dconf->data() + chunkPtr),chunkLen);
|
outp.append((const void *)(dconf->data() + chunkIndex),chunkLen);
|
||||||
outp.append((uint32_t)totalSize);
|
outp.append((uint32_t)totalSize);
|
||||||
outp.append((uint32_t)chunkPtr);
|
outp.append((uint32_t)chunkIndex);
|
||||||
outp.compress();
|
outp.compress();
|
||||||
RR->sw->send(outp,true,0);
|
RR->sw->send(outp,true,0);
|
||||||
chunkPtr += chunkLen;
|
chunkIndex += chunkLen;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
delete dconf;
|
||||||
|
} catch ( ... ) {
|
||||||
|
delete dconf;
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
delete dconf;
|
} break;
|
||||||
} catch ( ... ) {
|
|
||||||
delete dconf;
|
|
||||||
throw;
|
|
||||||
}
|
|
||||||
} break;
|
|
||||||
|
|
||||||
case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND: {
|
case NetworkController::NETCONF_QUERY_OBJECT_NOT_FOUND: {
|
||||||
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
||||||
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
||||||
outp.append(requestPacketId);
|
outp.append(requestPacketId);
|
||||||
outp.append((unsigned char)Packet::ERROR_OBJ_NOT_FOUND);
|
outp.append((unsigned char)Packet::ERROR_OBJ_NOT_FOUND);
|
||||||
outp.append(nwid);
|
outp.append(nwid);
|
||||||
outp.armor(peer->key(),true);
|
outp.armor(peer->key(),true);
|
||||||
RR->node->putPacket(_localAddress,_remoteAddress,outp.data(),outp.size());
|
RR->node->putPacket(_localAddress,_remoteAddress,outp.data(),outp.size());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NetworkController::NETCONF_QUERY_ACCESS_DENIED: {
|
case NetworkController::NETCONF_QUERY_ACCESS_DENIED: {
|
||||||
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
||||||
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
outp.append((unsigned char)Packet::VERB_NETWORK_CONFIG_REQUEST);
|
||||||
outp.append(requestPacketId);
|
outp.append(requestPacketId);
|
||||||
outp.append((unsigned char)Packet::ERROR_NETWORK_ACCESS_DENIED_);
|
outp.append((unsigned char)Packet::ERROR_NETWORK_ACCESS_DENIED_);
|
||||||
outp.append(nwid);
|
outp.append(nwid);
|
||||||
outp.armor(peer->key(),true);
|
outp.armor(peer->key(),true);
|
||||||
RR->node->putPacket(_localAddress,_remoteAddress,outp.data(),outp.size());
|
RR->node->putPacket(_localAddress,_remoteAddress,outp.data(),outp.size());
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NetworkController::NETCONF_QUERY_INTERNAL_SERVER_ERROR:
|
|
||||||
break;
|
|
||||||
|
|
||||||
case NetworkController::NETCONF_QUERY_IGNORE:
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
TRACE("NETWORK_CONFIG_REQUEST failed: invalid return value from NetworkController::doNetworkConfigRequest()");
|
|
||||||
break;
|
|
||||||
|
|
||||||
|
case NetworkController::NETCONF_QUERY_INTERNAL_SERVER_ERROR:
|
||||||
|
break;
|
||||||
|
case NetworkController::NETCONF_QUERY_IGNORE:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
TRACE("NETWORK_CONFIG_REQUEST failed: invalid return value from NetworkController::doNetworkConfigRequest()");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
delete netconf;
|
||||||
|
} catch ( ... ) {
|
||||||
|
delete netconf;
|
||||||
|
throw;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
Packet outp(peer->address(),RR->identity.address(),Packet::VERB_ERROR);
|
||||||
@ -801,6 +805,24 @@ bool IncomingPacket::_doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,cons
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool IncomingPacket::_doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
|
||||||
|
{
|
||||||
|
try {
|
||||||
|
unsigned int p = ZT_PACKET_IDX_PAYLOAD;
|
||||||
|
while ((p + 8) <= size()) {
|
||||||
|
const uint64_t nwid = at<uint64_t>(p); p += 8;
|
||||||
|
if (Network::controllerFor(nwid) == peer->address()) {
|
||||||
|
SharedPtr<Network> network(RR->node->network(nwid));
|
||||||
|
if (network)
|
||||||
|
network->requestConfiguration();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch ( ... ) {
|
||||||
|
TRACE("dropped NETWORK_CONFIG_REFRESH from %s(%s): unexpected exception",source().toString().c_str(),_remoteAddress.toString().c_str());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool IncomingPacket::_doMULTICAST_GATHER(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
|
bool IncomingPacket::_doMULTICAST_GATHER(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
|
@ -165,6 +165,7 @@ private:
|
|||||||
bool _doMULTICAST_LIKE(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
bool _doMULTICAST_LIKE(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
||||||
bool _doNETWORK_CREDENTIALS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
bool _doNETWORK_CREDENTIALS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
||||||
bool _doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
bool _doNETWORK_CONFIG_REQUEST(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
||||||
|
bool _doNETWORK_CONFIG_REFRESH(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
||||||
bool _doMULTICAST_GATHER(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
bool _doMULTICAST_GATHER(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
||||||
bool _doMULTICAST_FRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
bool _doMULTICAST_FRAME(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
||||||
bool _doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
bool _doPUSH_DIRECT_PATHS(const RuntimeEnvironment *RR,const SharedPtr<Peer> &peer);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user