]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
geoipbackend: Add per-AFI IP expansions
authorAki Tuomi <cmouse@cmouse.fi>
Mon, 1 Jan 2018 15:24:46 +0000 (17:24 +0200)
committerAki Tuomi <cmouse@cmouse.fi>
Wed, 14 Feb 2018 07:15:53 +0000 (09:15 +0200)
Allows records like A %ip4 AAAA %ip6.

modules/geoipbackend/geoipbackend.cc

index 856a3335b3a6cff3bf8f44d54f577055fd89b090..5d9def6eba447cc529b6f38ec9ebaa9eebfa2323 100644 (file)
@@ -555,6 +555,20 @@ string GeoIPBackend::format2str(string sformat, const string& ip, bool v6, GeoIP
     } else if (!sformat.compare(cur,3,"%mo")) {
       rep = boost::str(boost::format("%02d") % (gtm.tm_mon + 1));
       tmp_gl.netmask = (v6?128:32);
+    } else if (!sformat.compare(cur,4,"%ip6")) {
+      nrep = 4;
+      if (v6)
+        rep = ip;
+      else
+        rep = "";
+      tmp_gl.netmask = (v6?128:32);
+    } else if (!sformat.compare(cur,4,"%ip4")) {
+      nrep = 4;
+      if (!v6)
+        rep = ip;
+      else
+        rep = "";
+      tmp_gl.netmask = (v6?128:32);
     } else if (!sformat.compare(cur,3,"%ip")) {
       rep = ip;
       tmp_gl.netmask = (v6?128:32);