Implemented certbot helper utility
This commit is contained in:
parent
87aac99c54
commit
4c3dfa829f
6 changed files with 224 additions and 14 deletions
|
@ -478,6 +478,10 @@ void Controller::handleAPICommands(JSON::Value & Request, JSON::Value & Response
|
|||
if (Request["updateprotocol"].isArray() && Request["updateprotocol"].size() == 2){
|
||||
jsonForEach(Controller::Storage["config"]["protocols"], it){
|
||||
if ((*it).compareExcept(Request["updateprotocol"][0u], ignores)){
|
||||
//If the connector type didn't change, mark it as needing a reload
|
||||
if ((*it)["connector"] == Request["updateprotocol"][1u]["connector"]){
|
||||
reloadProtocol(it.num());
|
||||
}
|
||||
(*it) = Request["updateprotocol"][1u];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,13 @@
|
|||
///\brief Holds everything unique to the controller.
|
||||
namespace Controller {
|
||||
|
||||
static std::set<size_t> needsReload; ///< List of connector indices that needs a reload
|
||||
static std::map<std::string, pid_t> currentConnectors; ///<The currently running connectors.
|
||||
|
||||
void reloadProtocol(size_t indice){
|
||||
needsReload.insert(indice);
|
||||
}
|
||||
|
||||
/// Updates the shared memory page with active connectors
|
||||
void saveActiveConnectors(bool forceOverride){
|
||||
IPC::sharedPage f("MstCnns", 4096, forceOverride, false);
|
||||
|
@ -90,18 +95,6 @@ namespace Controller {
|
|||
currentConnectors.clear();
|
||||
}
|
||||
|
||||
///\brief Checks if the binary mentioned in the protocol argument is currently active, if so, restarts it.
|
||||
///\param protocol The protocol to check.
|
||||
void UpdateProtocol(std::string protocol){
|
||||
std::map<std::string, pid_t>::iterator iter;
|
||||
for (iter = currentConnectors.begin(); iter != currentConnectors.end(); iter++){
|
||||
if (iter->first.substr(0, protocol.size()) == protocol){
|
||||
Log("CONF", "Killing connector for update: " + iter->first);
|
||||
Util::Procs::Stop(iter->second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static inline void builPipedPart(JSON::Value & p, char * argarr[], int & argnum, const JSON::Value & argset){
|
||||
jsonForEachConst(argset, it) {
|
||||
if (it->isMember("option")){
|
||||
|
@ -203,6 +196,11 @@ namespace Controller {
|
|||
runningConns.insert(myCmd);
|
||||
if (currentConnectors.count(myCmd) && Util::Procs::isActive(currentConnectors[myCmd])){
|
||||
( *ait)["online"] = 1;
|
||||
//Reload connectors that need it
|
||||
if (needsReload.count(ait.num())){
|
||||
kill(currentConnectors[myCmd], SIGUSR1);
|
||||
needsReload.erase(ait.num());
|
||||
}
|
||||
}else{
|
||||
( *ait)["online"] = 0;
|
||||
}
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
|
||||
namespace Controller {
|
||||
|
||||
/// Checks if the binary mentioned in the protocol argument is currently active, if so, restarts it.
|
||||
void UpdateProtocol(std::string protocol);
|
||||
/// Marks the given protocol as needing a reload (signal USR1) on next check
|
||||
void reloadProtocol(size_t indice);
|
||||
|
||||
/// Checks current protocol configuration, updates state of enabled connectors if neccesary.
|
||||
bool CheckProtocols(JSON::Value & p, const JSON::Value & capabilities);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue