From: Pieter Lexis Date: Mon, 18 Feb 2019 10:20:02 +0000 (+0100) Subject: LUA records: set User-Agent string X-Git-Tag: auth-4.2.0-beta1~6^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=192e15fc13bd1f179ef137d0e4e09a6195c9e0b8;p=thirdparty%2Fpdns.git LUA records: set User-Agent string Closes #7393 --- diff --git a/docs/lua-records/functions.rst b/docs/lua-records/functions.rst index b655cb1449..7cbbe086bc 100644 --- a/docs/lua-records/functions.rst +++ b/docs/lua-records/functions.rst @@ -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: diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index 429069e4e2..ce0170bce8 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -1,3 +1,4 @@ +#include "version.hh" #include "ext/luawrapper/include/LuaContext.hpp" #include "lua-auth4.hh" #include @@ -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")) {