From: Peter van Dijk Date: Tue, 20 Dec 2022 20:37:56 +0000 (+0100) Subject: auth LUA createForward6: accept hex-only addresses, with an optional prefix X-Git-Tag: dnsdist-1.8.0-rc3~11^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ada6063ac53498a67fb8863e9ddafcb365d02509;p=thirdparty%2Fpdns.git auth LUA createForward6: accept hex-only addresses, with an optional prefix --- diff --git a/pdns/lua-record.cc b/pdns/lua-record.cc index e231da745b..8511ffd687 100644 --- a/pdns/lua-record.cc +++ b/pdns/lua-record.cc @@ -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("::");