This commit is contained in:
Adam Ierymenko 2016-08-23 11:52:10 -07:00
parent 0dfc08b317
commit 68b4ca9b31
3 changed files with 4 additions and 15 deletions

View File

@ -416,7 +416,7 @@ Network::Network(const RuntimeEnvironment *renv,uint64_t nwid,void *uptr) :
std::string conf(RR->node->dataStoreGet(confn)); std::string conf(RR->node->dataStoreGet(confn));
if (conf.length()) { if (conf.length()) {
dconf->load(conf.c_str()); dconf->load(conf.c_str());
if (nconf->fromDictionary(Identity(),*dconf)) { if (nconf->fromDictionary(*dconf)) {
this->setConfiguration(*nconf,false); this->setConfiguration(*nconf,false);
_lastConfigUpdate = 0; // we still want to re-request a new config from the network _lastConfigUpdate = 0; // we still want to re-request a new config from the network
gotConf = true; gotConf = true;
@ -672,7 +672,7 @@ void Network::handleInboundConfigChunk(const uint64_t inRePacketId,const void *d
try { try {
Identity controllerId(RR->topology->getIdentity(this->controller())); Identity controllerId(RR->topology->getIdentity(this->controller()));
if (controllerId) { if (controllerId) {
if (nc->fromDictionary(controllerId,*dict)) { if (nc->fromDictionary(*dict)) {
this->setConfiguration(*nc,true); this->setConfiguration(*nc,true);
} else { } else {
TRACE("error parsing new config with length %u: deserialization of NetworkConfig failed (certificate error?)",(unsigned int)newConfig.length()); TRACE("error parsing new config with length %u: deserialization of NetworkConfig failed (certificate error?)",(unsigned int)newConfig.length());

View File

@ -179,18 +179,8 @@ bool NetworkConfig::toDictionary(Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d,b
return true; return true;
} }
bool NetworkConfig::fromDictionary(const Identity &controllerId,Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d) bool NetworkConfig::fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d)
{ {
if ((d.contains(ZT_NETWORKCONFIG_DICT_KEY_SIGNATURE))&&(controllerId)) {
// FIXME: right now signature are optional since network configs are only
// accepted directly from the controller and the protocol already guarantees
// the sender. In the future these might be made non-optional once old
// controllers that do not sign are gone and if we ever support peer caching
// of network configs.
if (!d.unwrapAndVerify(ZT_NETWORKCONFIG_DICT_KEY_SIGNATURE,controllerId.publicKey()))
return false;
}
Buffer<ZT_NETWORKCONFIG_DICT_CAPACITY> *tmp = new Buffer<ZT_NETWORKCONFIG_DICT_CAPACITY>(); Buffer<ZT_NETWORKCONFIG_DICT_CAPACITY> *tmp = new Buffer<ZT_NETWORKCONFIG_DICT_CAPACITY>();
try { try {

View File

@ -206,11 +206,10 @@ public:
/** /**
* Read this network config from a dictionary * Read this network config from a dictionary
* *
* @param controllerId Controller identity for verification of any signature or NULL identity to skip
* @param d Dictionary (non-const since it might be modified during parse, should not be used after call) * @param d Dictionary (non-const since it might be modified during parse, should not be used after call)
* @return True if dictionary was valid and network config successfully initialized * @return True if dictionary was valid and network config successfully initialized
*/ */
bool fromDictionary(const Identity &controllerId,Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d); bool fromDictionary(const Dictionary<ZT_NETWORKCONFIG_DICT_CAPACITY> &d);
/** /**
* @return True if passive bridging is allowed (experimental) * @return True if passive bridging is allowed (experimental)