With the diff option only modified options are included in the output.
Show the content of the cache.
-current-config
-^^^^^^^^^^^^^^
+current-config [diff]
+^^^^^^^^^^^^^^^^^^^^^
-Show the currently running configuration. The output has the same
-format as ``pdns_server --config``. You'll notice that all the
-configuration values are uncommented. This is because PowerDNS
-simply has values, and the default isn't known at runtime.
+Show the currently running configuration. The output has the same format as ``pdns_server --config``. With the diff option only modified options are included in the output.
cycle
^^^^^
--control-console Run the server in a special monitor mode. This enables detailed
logging and exposes the raw control socket.
--loglevel=<LEVEL> Set the logging level.
+--config Show the currently configuration. There are two optional values (defaul
+ is empty). --config=diff will only show modified options. --config=default
+ will show the default configuration.
--help To view more options that are available use this program.
See also
endif
pdns.conf-dist: pdns_server
- $(AM_V_GEN)./pdns_server --no-config --config 2>/dev/null > $@
+ $(AM_V_GEN)./pdns_server --no-config --config=default 2>/dev/null > $@
testrunner_SOURCES = \
arguments.cc \
return params[var];
}
+void ArgvMap::setDefault(const string &var, const string &value)
+{
+ if(! defaultmap.count(var))
+ defaultmap.insert(pair<string, string>(var, value));
+}
+
+void ArgvMap::setDefaults()
+{
+ for(map<string,string>::const_iterator i=params.begin();i!=params.end();++i)
+ if(! defaultmap.count(i->first))
+ defaultmap.insert(*i);
+}
+
bool ArgvMap::mustDo(const string &var)
{
return ((*this)[var]!="no") && ((*this)[var]!="off");
return help;
}
-string ArgvMap::configstring(bool current)
+string ArgvMap::configstring(bool running, bool full)
{
string help;
- if (current)
- help="# Autogenerated configuration file based on running instance\n";
+ if (running)
+ help="# Autogenerated configuration file based on running instance ("+nowTime()+")\n\n";
else
- help="# Autogenerated configuration file template\n";
-
+ help="# Autogenerated configuration file template\n\n";
+
for(const auto& i: helpmap) {
if(d_typeMap[i.first]=="Command")
continue;
- help+="#################################\n";
- help+="# ";
- help+=i.first;
- help+="\t";
- help+=i.second;
- help+="\n#\n";
- if (current) {
- help+=i.first+"="+params[i.first]+"\n\n";
+ if (! defaultmap.count(i.first)) {
+ throw ArgException(string("Default for parameter '")+i.first+"' not set");
+ }
+
+ if (!running || full) {
+ help+="#################################\n";
+ help+="# ";
+ help+=i.first;
+ help+="\t";
+ help+=i.second;
+ help+="\n#\n";
+ } else {
+ if (defaultmap[i.first] == params[i.first]) {
+ continue;
+ }
+ }
+
+ if (! running || defaultmap[i.first] == params[i.first]) {
+ help+="# ";
+ }
+
+ if (running) {
+ help+=i.first+"="+params[i.first]+"\n";
+ if (full) {
+ help+="\n";
+ }
} else {
- help+="# "+i.first+"="+params[i.first]+"\n\n";
+ help+=i.first+"="+defaultmap[i.first]+"\n\n";
}
}
return help;
void setCmd(const string &, const string &); //!< Add a command flag
string &setSwitch(const string &, const string &); //!< Add a switch flag
string helpstring(string prefix=""); //!< generates the --help
- string configstring(bool current=false); //!< generates the --mkconfig
+ string configstring(bool current, bool full); //!< generates the --config
bool contains(const string &var, const string &val);
bool isEmpty(const string &var); //!< checks if variable has value
+ void setDefault(const string &var, const string &value);
+ void setDefaults();
vector<string>list();
string getHelp(const string &item);
typedef map<string,string> params_t;
params_t params;
map<string,string> helpmap;
+ map<string,string> defaultmap;
map<string,string> d_typeMap;
vector<string> d_cmds;
std::set<string> d_cleared;
::arg().set("max-generate-steps", "Maximum number of $GENERATE steps when loading a zone from a file")="0";
::arg().set("rng", "Specify the random number generator to use. Valid values are auto,sodium,openssl,getrandom,arc4random,urandom.")="auto";
+ ::arg().setDefaults();
}
static time_t s_start=time(0);
{
string fullname=d_name+suffix+"-"+param;
arg().set(fullname,help)=value;
+ arg().setDefault(fullname,value);
}
const string &BackendFactory::getName() const
string DLCurrentConfigHandler(const vector<string>&parts, Utility::pid_t ppid)
{
- return ::arg().configstring(true);
+ if(parts.size() > 1) {
+ if(parts.size() == 2 && parts[1] == "diff") {
+ return ::arg().configstring(true, false);
+ }
+ return "Syntax: current-config [diff]";
+ }
+ return ::arg().configstring(true, true);
}
string DLRQuitHandler(const vector<string>&parts, Utility::pid_t ppid)
::arg().setCmd("help","Provide a helpful message");
::arg().setCmd("version","Print version string");
::arg().setCmd("config","Output blank configuration");
+ ::arg().setDefaults();
g_log.toConsole(Logger::Info);
::arg().laxParse(argc,argv); // do a lax parse
}
if(::arg().mustDo("config")) {
- cout<<::arg().configstring()<<endl;
+ cout<<::arg().configstring(false, true);
exit(0);
}
string configname=::arg()["config-dir"]+"/"+s_programname+".conf";
cleanSlashes(configname);
- if(!::arg().mustDo("config") && !::arg().mustDo("no-config")) // "config" == print a configuration file
+ if(!::arg().mustDo("no-config")) // "config" == print a configuration file
::arg().laxFile(configname.c_str());
::arg().laxParse(argc,argv); // reparse so the commandline still wins
}
if(::arg().mustDo("config")) {
- cout<<::arg().configstring()<<endl;
+ string config = ::arg()["config"];
+ if (config == "default") {
+ cout<<::arg().configstring(false, true);
+ } else if (config == "diff") {
+ cout<<::arg().configstring(true, false);
+ } else {
+ cout<<::arg().configstring(true, true);
+ }
exit(0);
}
DynListener::registerFunc("REMOTES", &DLRemotesHandler, "get top remotes");
DynListener::registerFunc("SET",&DLSettingsHandler, "set config variables", "<var> <value>");
DynListener::registerFunc("RETRIEVE",&DLNotifyRetrieveHandler, "retrieve slave domain", "<domain>");
- DynListener::registerFunc("CURRENT-CONFIG",&DLCurrentConfigHandler, "retrieve the current configuration");
+ DynListener::registerFunc("CURRENT-CONFIG",&DLCurrentConfigHandler, "retrieve the current configuration", "[diff|default]");
DynListener::registerFunc("LIST-ZONES",&DLListZones, "show list of zones", "[master|slave|native]");
DynListener::registerFunc("TOKEN-LOGIN", &DLTokenLogin, "Login to a PKCS#11 token", "<module> <slot> <pin>");