]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: Only expose SNMP helpers when SNMP is built in
authorRemi Gacogne <remi.gacogne@powerdns.com>
Fri, 12 Nov 2021 15:10:16 +0000 (16:10 +0100)
committerRemi Gacogne <remi.gacogne@powerdns.com>
Wed, 22 Dec 2021 08:30:44 +0000 (09:30 +0100)
pdns/dnsdist-lua.cc

index 69dc8efc436c1a8cf84d9555d18ba8891c0aea12..1e7bf17dc20cdaf18e88f5334046e6cdff2fc253 100644 (file)
@@ -1951,10 +1951,10 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
 
   luaCtx.writeFunction("setTCPInternalPipeBufferSize", [](uint64_t size) { g_tcpInternalPipeBufferSize = size; });
 
+#ifdef HAVE_NET_SNMP
   luaCtx.writeFunction("snmpAgent", [client, configCheck](bool enableTraps, boost::optional<std::string> daemonSocket) {
     if (client || configCheck)
       return;
-#ifdef HAVE_NET_SNMP
     if (g_configurationDone) {
       errlog("snmpAgent() cannot be used at runtime!");
       g_outputBuffer = "snmpAgent() cannot be used at runtime!\n";
@@ -1970,10 +1970,6 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
     g_snmpEnabled = true;
     g_snmpTrapsEnabled = enableTraps;
     g_snmpAgent = new DNSDistSNMPAgent("dnsdist", daemonSocket ? *daemonSocket : std::string());
-#else
-      errlog("NET SNMP support is required to use snmpAgent()");
-      g_outputBuffer = "NET SNMP support is required to use snmpAgent()\n";
-#endif /* HAVE_NET_SNMP */
   });
 
   luaCtx.writeFunction("sendCustomTrap", [](const std::string& str) {
@@ -1981,6 +1977,7 @@ static void setupLuaConfig(LuaContext& luaCtx, bool client, bool configCheck)
       g_snmpAgent->sendCustomTrap(str);
     }
   });
+#endif /* HAVE_NET_SNMP */
 
   luaCtx.writeFunction("setServerPolicy", [](const ServerPolicy& policy) {
     setLuaSideEffect();