From: Miod Vallat Date: Thu, 9 Jan 2025 14:05:55 +0000 (+0100) Subject: Move add-zone-key logic to its own routine. NFC X-Git-Tag: dnsdist-2.0.0-alpha1~175^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9b7a612889f72c2ce7fccc4953682cc15913a21b;p=thirdparty%2Fpdns.git Move add-zone-key logic to its own routine. NFC --- diff --git a/pdns/pdnsutil.cc b/pdns/pdnsutil.cc index ed19662297..b0f71c63d9 100644 --- a/pdns/pdnsutil.cc +++ b/pdns/pdnsutil.cc @@ -2515,6 +2515,85 @@ static int addOrSetMeta(const DNSName& zone, const string& kind, const vector& cmds, DNSSECKeeper& dk) +{ + if(cmds.size() < 3 ) { + cerr << "Syntax: pdnsutil add-zone-key ZONE [zsk|ksk] [BITS] [active|inactive] [rsasha1|rsasha1-nsec3-sha1|rsasha256|rsasha512|ecdsa256|ecdsa384"; +#if defined(HAVE_LIBSODIUM) || defined(HAVE_LIBCRYPTO_ED25519) + cerr << "|ed25519"; +#endif +#if defined(HAVE_LIBCRYPTO_ED448) + cerr << "|ed448"; +#endif + cerr << "]"< 0) { + algorithm = tmp_algo; + } + else if (pdns_iequals(cmds.at(n), "active")) { + active=true; + } + else if (pdns_iequals(cmds.at(n), "inactive") || pdns_iequals(cmds.at(n), "passive")) { // 'passive' eventually needs to be removed + active=false; + } + else if (pdns_iequals(cmds.at(n), "published")) { + published = true; + } + else if (pdns_iequals(cmds.at(n), "unpublished")) { + published = false; + } + else if (pdns::checked_stoi(cmds.at(n)) != 0) { + pdns::checked_stoi_into(bits, cmds.at(n)); + } + else { + cerr << "Unknown algorithm, key flag or size '" << cmds.at(n) << "'" << endl; + return EXIT_FAILURE; + } + } + int64_t id{-1}; + if (!dk.addKey(zone, keyOrZone, algorithm, id, bits, active, published)) { + cerr<<"Adding key failed, perhaps DNSSEC not enabled in configuration?"< 0) { - algorithm = tmp_algo; - } - else if (pdns_iequals(cmds.at(n), "active")) { - active=true; - } - else if (pdns_iequals(cmds.at(n), "inactive") || pdns_iequals(cmds.at(n), "passive")) { // 'passive' eventually needs to be removed - active=false; - } - else if (pdns_iequals(cmds.at(n), "published")) { - published = true; - } - else if (pdns_iequals(cmds.at(n), "unpublished")) { - published = false; - } - else if (pdns::checked_stoi(cmds.at(n)) != 0) { - pdns::checked_stoi_into(bits, cmds.at(n)); - } - else { - cerr << "Unknown algorithm, key flag or size '" << cmds.at(n) << "'" << endl; - return EXIT_FAILURE; - } - } - int64_t id{-1}; - if (!dk.addKey(zone, keyOrZone, algorithm, id, bits, active, published)) { - cerr<<"Adding key failed, perhaps DNSSEC not enabled in configuration?"<