]> granicus.if.org Git - pdns/commitdiff
LUA records: set User-Agent string
authorPieter Lexis <pieter.lexis@powerdns.com>
Mon, 18 Feb 2019 10:20:02 +0000 (11:20 +0100)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 18 Feb 2019 10:20:02 +0000 (11:20 +0100)
Closes #7393

docs/lua-records/functions.rst
pdns/lua-record.cc

index b655cb144974aca2a4e341ecebbc43cc42c0f06d..7cbbe086bc0fe7e06d1150366d83909ca63e4e95 100644 (file)
@@ -69,6 +69,7 @@ Record creation functions
   - ``backupSelector``: used to pick the IP address from list of all candidates if all addresses are down. Choices include 'pickclosest', 'random', 'hashed', 'all' (default to 'random').
   - ``source``: Source IP address to check from
   - ``stringmatch``: check ``url`` for this string, only declare 'up' if found
+  - ``useragent``: Set the HTTP "User-Agent" header in the requests. By default it is set to "PowerDNS Authoritative Server/" plus the version number
 
   An example of IP address sets:
 
index 429069e4e2d76baf993facfe6b3fcfcb9b00e4ef..ce0170bce81d6a7b8dac66ce27f37a25409c0475 100644 (file)
@@ -1,3 +1,4 @@
+#include "version.hh"
 #include "ext/luawrapper/include/LuaContext.hpp"
 #include "lua-auth4.hh"
 #include <thread>
@@ -184,7 +185,11 @@ void IsUpOracle::checkURLThread(ComboAddress rem, std::string url, const opts_t&
   setDown(rem, url, opts);
   for(bool first=true;;first=false) {
     try {
-      MiniCurl mc;
+      string useragent = productName() + "/" + getPDNSVersion();
+      if (opts.count("useragent")) {
+        useragent = opts.at("useragent");
+      }
+      MiniCurl mc(useragent);
 
       string content;
       if(opts.count("source")) {