]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
dnsdist: add setConsoleOutputMaxMsgSize function to tune console output message maxim... 7109/head
authorCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Fri, 26 Oct 2018 15:21:28 +0000 (17:21 +0200)
committerCharles-Henri Bruyand <charles-henri.bruyand@open-xchange.com>
Fri, 26 Oct 2018 15:21:28 +0000 (17:21 +0200)
pdns/dnsdist-console.cc
pdns/dnsdist-console.hh
pdns/dnsdist-lua.cc
pdns/dnsdist-tcp.cc
pdns/dnsdistdist/docs/reference/config.rst

index 53210fe8540934940849108a6d52d5cf1700d7f4..d0195c9ecc766f2bae176d3e636403d5afda70d8 100644 (file)
@@ -44,6 +44,7 @@ vector<pair<struct timeval, string> > g_confDelta;
 std::string g_consoleKey;
 bool g_logConsoleConnections{true};
 bool g_consoleEnabled{false};
+uint32_t g_consoleOutputMsgMaxSize{10000000};
 
 // MUST BE CALLED UNDER A LOCK - right now the LuaLock
 static void feedConfigDelta(const std::string& line)
@@ -412,6 +413,7 @@ const std::vector<ConsoleKeyword> g_consoleKeywords{
   { "setAPIWritable", true, "bool, dir", "allow modifications via the API. if `dir` is set, it must be a valid directory where the configuration files will be written by the API" },
   { "setConsoleACL", true, "{netmask, netmask}", "replace the console ACL set with these netmasks" },
   { "setConsoleConnectionsLogging", true, "enabled", "whether to log the opening and closing of console connections" },
+  { "setConsoleOutputMaxMsgSize", true, "messageSize", "set console message maximum size in bytes, default is 10 MB" },
   { "setDNSSECPool", true, "pool name", "move queries requesting DNSSEC processing to this pool" },
   { "setDynBlocksAction", true, "action", "set which action is performed when a query is blocked. Only DNSAction.Drop (the default) and DNSAction.Refused are supported" },
   { "setECSOverride", true, "bool", "whether to override an existing EDNS Client Subnet value in the query" },
@@ -700,3 +702,30 @@ catch(const std::exception& e)
   close(fd);
   errlog("Control connection died: %s", e.what());
 }
+
+bool getMsgLen32(int fd, uint32_t* len)
+try
+{
+  uint32_t raw;
+  size_t ret = readn2(fd, &raw, sizeof raw);
+  if(ret != sizeof raw)
+    return false;
+  *len = ntohl(raw);
+  if(*len > g_consoleOutputMsgMaxSize)
+    return false;
+  return true;
+}
+catch(...) {
+   return false;
+}
+
+bool putMsgLen32(int fd, uint32_t len)
+try
+{
+  uint32_t raw = htonl(len);
+  size_t ret = writen2(fd, &raw, sizeof raw);
+  return ret==sizeof raw;
+}
+catch(...) {
+  return false;
+}
index 7de8b68454f8bb3c10f67e015e3e60c9f810af61..1c3bb6e2f878118b56e884a243dfbee55e966be3 100644 (file)
@@ -43,6 +43,7 @@ extern const std::vector<ConsoleKeyword> g_consoleKeywords;
 extern std::string g_consoleKey; // in theory needs locking
 extern bool g_logConsoleConnections;
 extern bool g_consoleEnabled;
+extern uint32_t g_consoleOutputMsgMaxSize;
 
 void doClient(ComboAddress server, const std::string& command);
 void doConsole();
index 00bb216518ad68509f70621b14350e625f48723f..40abb4bce865c5b91f718a57f4042fb3fc55dd82 100644 (file)
@@ -1469,6 +1469,10 @@ void setupLuaConfig(bool client)
       g_logConsoleConnections = enabled;
     });
 
+  g_lua.writeFunction("setConsoleOutputMaxMsgSize", [](uint32_t size) {
+      g_consoleOutputMsgMaxSize = size;
+    });
+
   g_lua.writeFunction("setUDPMultipleMessagesVectorSize", [](size_t vSize) {
       if (g_configurationDone) {
         errlog("setUDPMultipleMessagesVectorSize() cannot be used at runtime!");
index 9eba8619142117f6bc936ab58710d24b78ba6a21..b918c79689f0f5a9f8619d798e48cc2a891fcf26 100644 (file)
@@ -776,30 +776,3 @@ void* tcpAcceptorThread(void* p)
 
   return 0;
 }
-
-bool getMsgLen32(int fd, uint32_t* len)
-try
-{
-  uint32_t raw;
-  size_t ret = readn2(fd, &raw, sizeof raw);
-  if(ret != sizeof raw)
-    return false;
-  *len = ntohl(raw);
-  if(*len > 10000000) // arbitrary 10MB limit
-    return false;
-  return true;
-}
-catch(...) {
-   return false;
-}
-
-bool putMsgLen32(int fd, uint32_t len)
-try
-{
-  uint32_t raw = htonl(len);
-  size_t ret = writen2(fd, &raw, sizeof raw);
-  return ret==sizeof raw;
-}
-catch(...) {
-  return false;
-}
index 90da2e703fcf6e5595aa2870b925264b7162234f..345a255410b22998045a5af7255627e7c8ee3cdf 100644 (file)
@@ -203,6 +203,14 @@ Control Socket, Console and Webserver
 
   Test the crypto code, will report errors when something is not ok.
 
+.. function:: setConsoleOutputMaxMsgSize(size)
+
+  .. versionadded:: 1.3.3
+
+  Set the maximum size in bytes of a single console message, default set to 10 MB.
+
+  :param int size: The new maximum size.
+
 Webserver
 ~~~~~~~~~