]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
auth LUA createForward6: accept hex-only addresses, with an optional prefix
authorPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 20 Dec 2022 20:37:56 +0000 (21:37 +0100)
committerPeter van Dijk <peter.van.dijk@powerdns.com>
Tue, 20 Dec 2022 20:38:10 +0000 (21:38 +0100)
pdns/lua-record.cc

index e231da745ba67c1bd1d26e642e47d1cbbbeea659..8511ffd687d1f9b2434ab4a583d7dc01aaeea929 100644 (file)
@@ -726,9 +726,27 @@ static void setupLuaRecords(LuaContext& lua)
         return ca.toString();
       }
       else if(parts.size()==1) {
-        boost::replace_all(parts[0],"-",":");
-        ComboAddress ca(parts[0]);
-        return ca.toString();
+        if (parts[0].find('-') != std::string::npos) {
+          boost::replace_all(parts[0],"-",":");
+          ComboAddress ca(parts[0]);
+          return ca.toString();
+        } else {
+          if (parts[0].size() >= 32) {
+            auto ippart = parts[0].substr(parts[0].size()-32);
+            auto fulladdress =
+              ippart.substr(0, 4) + ":" +
+              ippart.substr(4, 4) + ":" +
+              ippart.substr(8, 4) + ":" +
+              ippart.substr(12, 4) + ":" +
+              ippart.substr(16, 4) + ":" +
+              ippart.substr(20, 4) + ":" +
+              ippart.substr(24, 4) + ":" +
+              ippart.substr(28, 4);
+
+            ComboAddress ca(fulladdress);
+            return ca.toString();
+          }
+        }
       }
 
       return std::string("::");