]> git.ipfire.org Git - thirdparty/pdns.git/blame - pdns/auth-catalogzone.hh
dnsdist: Fix DNS over plain HTTP broken by `reloadAllCertificates()`
[thirdparty/pdns.git] / pdns / auth-catalogzone.hh
CommitLineData
ddeea7a6
KM
1/*
2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 */
22
23#pragma once
24
25#include "ext/json11/json11.hpp"
8a66a927 26#include "base32.hh"
8a66a927
KM
27#include "dnssecinfra.hh"
28
29struct DomainInfo;
30
31typedef map<DNSName, pdns::SHADigest> CatalogHashMap;
ddeea7a6
KM
32
33class CatalogInfo
34{
35public:
36 enum CatalogType : uint8_t
37 {
38 None,
39 Producer,
40 Consumer
41 };
42
07545dbd 43 static const string& getTypeString(enum CatalogType type)
ddeea7a6 44 {
07545dbd
AV
45 static const std::array<const string, 3> types = {"none", "producer", "consumer"};
46 return types.at(type);
ddeea7a6
KM
47 }
48
49 CatalogInfo() :
8a66a927
KM
50 d_id(0), d_type(CatalogType::None) {}
51 CatalogInfo(uint32_t id, const DNSName& zone, const std::string& options, CatalogType type)
ddeea7a6 52 {
8a66a927
KM
53 d_id = id;
54 d_zone = zone;
55 fromJson(options, type);
ddeea7a6
KM
56 }
57
ddeea7a6
KM
58 void fromJson(const std::string& json, CatalogType type);
59 std::string toJson() const;
73f9bdd8 60 void setType(CatalogType type) { d_type = type; }
ddeea7a6
KM
61
62 void updateHash(CatalogHashMap& hashes, const DomainInfo& di) const;
8a66a927
KM
63 DNSName getUnique() const { return DNSName(toBase32Hex(hashQNameWithSalt(std::to_string(d_id), 0, d_zone))); } // salt with domain id to detect recreated zones
64 static DNSZoneRecord getCatalogVersionRecord(const DNSName& zone);
65 void toDNSZoneRecords(const DNSName& zone, vector<DNSZoneRecord>& dzrs) const;
ddeea7a6
KM
66
67 bool operator<(const CatalogInfo& rhs) const
68 {
8a66a927 69 return d_zone < rhs.d_zone;
ddeea7a6
KM
70 }
71
8a66a927
KM
72 uint32_t d_id;
73 DNSName d_zone, d_coo, d_unique;
aa6ee2f1 74 std::set<std::string> d_group;
73f9bdd8 75 vector<ComboAddress> d_primaries;
ddeea7a6
KM
76
77private:
78 CatalogType d_type;
79 json11::Json d_doc;
80};