2
0
mirror of https://gitlab.isc.org/isc-projects/kea synced 2025-08-28 12:37:55 +00:00
This commit is contained in:
Francis Dupont 2023-06-28 16:51:57 +02:00
parent 7a375cf743
commit a3c87ba5f4
4 changed files with 13 additions and 10 deletions

View File

@ -974,8 +974,9 @@ configureDhcp4Server(Dhcpv4Srv& server, isc::data::ConstElementPtr config_set,
.arg(CfgMgr::instance().getStagingCfg()->
getConfigSummary(SrvConfig::CFGSEL_ALL4));
// Also calculate SHA256 hash of the config that was just set and append it to the response.
ElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();
// Also calculate SHA256 hash of the config that was just set and
// append it to the response.
ConstElementPtr config = CfgMgr::instance().getStagingCfg()->toElement();
string hash = BaseCommandMgr::getHash(config);
ElementPtr hash_map = Element::createMap();
hash_map->set("hash", Element::create(hash));

View File

@ -1099,8 +1099,9 @@ configureDhcp6Server(Dhcpv6Srv& server, isc::data::ConstElementPtr config_set,
.arg(CfgMgr::instance().getStagingCfg()->
getConfigSummary(SrvConfig::CFGSEL_ALL6));
// Also calculate SHA256 hash of the config that was just set and append it to the response.
ElementPtr config = CfgMgr::instance().getCurrentCfg()->toElement();
// Also calculate SHA256 hash of the config that was just set and
// append it to the response.
ConstElementPtr config = CfgMgr::instance().getStagingCfg()->toElement();
string hash = BaseCommandMgr::getHash(config);
ElementPtr hash_map = Element::createMap();
hash_map->set("hash", Element::create(hash));

View File

@ -1,4 +1,4 @@
// Copyright (C) 2017-2022 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@ -191,7 +191,7 @@ BaseCommandMgr::listCommandsHandler(const std::string& /* name */,
}
std::string
BaseCommandMgr::getHash(isc::data::ElementPtr& config) {
BaseCommandMgr::getHash(const isc::data::ConstElementPtr& config) {
// First, get the string representation.
std::string config_txt = config->str();

View File

@ -1,4 +1,4 @@
// Copyright (C) 2017-2020 Internet Systems Consortium, Inc. ("ISC")
// Copyright (C) 2017-2023 Internet Systems Consortium, Inc. ("ISC")
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
@ -155,11 +155,12 @@ public:
/// @brief returns a hash of a given Element structure
///
/// The hash is currently implemented as SHA256 on the string represenation of the structure.
/// The hash is currently implemented as SHA256 on the string
// representation of the structure.
///
/// @param config typically full config, but hash can be calculated on any structure
/// @return string representation
static std::string getHash(isc::data::ElementPtr& config);
/// @return hash of string representation
static std::string getHash(const isc::data::ConstElementPtr& config);
protected: