knot_rrset_t* key; /**< Zone cut DNSKEY. */
knot_rrset_t* trust_anchor; /**< Current trust anchor. */
struct kr_zonecut *parent; /**< Parent zone cut. */
- map_t nsset; /**< Map of nameserver => address_set. */
+ map_t nsset; /**< Map of nameserver => address_set. */
knot_mm_t *pool; /**< Memory pool. */
};
:return: ``{ result: [address1, address2, ...] }``
Return list of address record matching given name.
+ If no hostname is specified, all hints are returned in the table format used by ``hints.root()``.
.. function:: hints.set(pair)
.. function:: hints.root()
- :return: ``{ ['a.root-servers.net'] = { '1.2.3.4', '5.6.7.8', ...}, ... }``
+ :return: ``{ ['a.root-servers.net.'] = { '1.2.3.4', '5.6.7.8', ...}, ... }``
.. tip:: If no parameters are passed, returns current root hints set.
.. function:: hints.root(root_hints)
:param table root_hints: new set of root hints i.e. ``{['name'] = 'addr', ...}``
- :return: ``{ ['a.root-servers.net'] = { '1.2.3.4', '5.6.7.8', ...}, ... }``
+ :return: ``{ ['a.root-servers.net.'] = { '1.2.3.4', '5.6.7.8', ...}, ... }``
Replace current root hints and return the current table of root hints.
return root;
}
+static char* pack_hints(struct kr_zonecut *hints);
/**
- * Retrieve address hint for given name.
+ * Retrieve address hints, either for given name or for all names.
*
* Input: name
* Output: { address1, address2, ... }
static char* hint_get(void *env, struct kr_module *module, const char *args)
{
struct kr_zonecut *hints = module->data;
+
+ if (!args) {
+ return pack_hints(hints);
+ }
+
knot_dname_t key[KNOT_DNAME_MAXLEN];
pack_t *pack = NULL;
if (knot_dname_from_str(key, args, sizeof(key))) {
return kr_ok();
}
+/** @internal Pack all hints into serialized JSON. */
+static char* pack_hints(struct kr_zonecut *hints) {
+ char *result = NULL;
+ JsonNode *root_node = json_mkobject();
+ if (map_walk(&hints->nsset, pack_hint, root_node) == 0) {
+ result = json_encode(root_node);
+ }
+ json_delete(root_node);
+ return result;
+}
+
static void unpack_hint(struct kr_zonecut *root_hints, JsonNode *table, const char *name)
{
JsonNode *node = NULL;
json_delete(root_node);
}
/* Return current root hints */
- char *result = NULL;
- JsonNode *root_node = json_mkobject();
- if (map_walk(&root_hints->nsset, pack_hint, root_node) == 0) {
- result = json_encode(root_node);
- }
- json_delete(root_node);
- return result;
+ return pack_hints(root_hints);
}
/*