Skip to content
Snippets Groups Projects
Commit 0c2edbf3 authored by Vladimír Čunát's avatar Vladimír Čunát
Browse files

zonecut: add auto-generation of root hints

Fixes #100.
The file with the addresses is in the repo, so people don't have to
regenerate it, but the build system is able to do it.
parent 1e73121b
Branches
Tags
No related merge requests found
......@@ -65,6 +65,10 @@ libkres_HEADERS += \
libkres_LIBS += $(nettle_LIBS)
endif
lib/zonecut.c: lib/root-hints.inc
lib/root-hints.inc: scripts/gen-root-hints.sh scripts/inet_pton.py
scripts/gen-root-hints.sh > $@
# Make library
ifeq ($(BUILDMODE), static)
$(eval $(call make_static,libkres,lib,yes))
......
/* generated root hints */
#define HINT_a_A "\xc6\x29\x00\x04"
#define HINT_b_A "\xc0\xe4\x4f\xc9"
#define HINT_c_A "\xc0\x21\x04\x0c"
#define HINT_d_A "\xc7\x07\x5b\x0d"
#define HINT_e_A "\xc0\xcb\xe6\x0a"
#define HINT_f_A "\xc0\x05\x05\xf1"
#define HINT_g_A "\xc0\x70\x24\x04"
#define HINT_h_A "\xc6\x61\xbe\x35"
#define HINT_i_A "\xc0\x24\x94\x11"
#define HINT_j_A "\xc0\x3a\x80\x1e"
#define HINT_k_A "\xc1\x00\x0e\x81"
#define HINT_l_A "\xc7\x07\x53\x2a"
#define HINT_m_A "\xca\x0c\x1b\x21"
#define HINT_a_AAAA "\x20\x01\x05\x03\xba\x3e\x00\x00\x00\x00\x00\x00\x00\x02\x00\x30"
#define HINT_b_AAAA "\x20\x01\x05\x00\x00\x84\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b"
#define HINT_c_AAAA "\x20\x01\x05\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c"
#define HINT_d_AAAA "\x20\x01\x05\x00\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0d"
#define HINT_e_AAAA "\x20\x01\x05\x00\x00\xa8\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0e"
#define HINT_f_AAAA "\x20\x01\x05\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f"
#define HINT_g_AAAA "\x20\x01\x05\x00\x00\x12\x00\x00\x00\x00\x00\x00\x00\x00\x0d\x0d"
#define HINT_h_AAAA "\x20\x01\x05\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x53"
#define HINT_i_AAAA "\x20\x01\x07\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x53"
#define HINT_j_AAAA "\x20\x01\x05\x03\x0c\x27\x00\x00\x00\x00\x00\x00\x00\x02\x00\x30"
#define HINT_k_AAAA "\x20\x01\x07\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01"
#define HINT_l_AAAA "\x20\x01\x05\x00\x00\x9f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x42"
#define HINT_m_AAAA "\x20\x01\x0d\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x35"
......@@ -34,39 +34,49 @@ struct hint_info {
const uint8_t *addr;
};
/* Initialize with SBELT name servers. */
#define U8(x) (const uint8_t *)(x)
#define I4 sizeof(struct in_addr)
#define I6 sizeof(struct in6_addr)
#define HINT_COUNT 24
static const struct hint_info SBELT[HINT_COUNT] = {
{ U8("\x01""j""\x0c""root-servers""\x03""net"), I4, U8("\xc0:\x80\x1e") }, /* 192.58.128.30 */
{ U8("\x01""k""\x0c""root-servers""\x03""net"), I4, U8("\xc1\x00\x0e\x81") }, /* 193.0.14.129 */
{ U8("\x01""d""\x0c""root-servers""\x03""net"), I4, U8("\xc7\x07[\r") }, /* 199.7.91.13 */
{ U8("\x01""e""\x0c""root-servers""\x03""net"), I4, U8("\xc0\xcb\xe6\n") }, /* 192.203.230.10 */
{ U8("\x01""f""\x0c""root-servers""\x03""net"), I4, U8("\xc0\x05\x05\xf1") }, /* 192.5.5.241 */
{ U8("\x01""g""\x0c""root-servers""\x03""net"), I4, U8("\xc0p$\x04") }, /* 192.112.36.4 */
{ U8("\x01""h""\x0c""root-servers""\x03""net"), I4, U8("\xc6\x61\xbe\x35") }, /* 198.97.190.53 */
{ U8("\x01""i""\x0c""root-servers""\x03""net"), I4, U8("\xc0$\x94\x11") }, /* 192.36.148.17 */
{ U8("\x01""l""\x0c""root-servers""\x03""net"), I4, U8("\xc7\x07S*") }, /* 199.7.83.42 */
{ U8("\x01""m""\x0c""root-servers""\x03""net"), I4, U8("\xca\x0c\x1b!") }, /* 202.12.27.33 */
{ U8("\x01""b""\x0c""root-servers""\x03""net"), I4, U8("\xc0\xe4O\xc9") }, /* 192.228.79.201 */
{ U8("\x01""c""\x0c""root-servers""\x03""net"), I4, U8("\xc6)\x00\x04") }, /* 192.33.4.12 */
{ U8("\x01""a""\x0c""root-servers""\x03""net"), I4, U8("\xc6)\x00\x04") }, /* 198.41.0.4 */
{ U8("\x01""a""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x03\xba\x3e\x00\x00\x00\x00\x00\x00\x00\x02\x00\x30") }, /* 2001:503:ba3e::2:30 */
{ U8("\x01""b""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x00\x00\x84\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0b") }, /* 2001:500:84::b */
{ U8("\x01""c""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x00\x00\x02\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0c") }, /* 2001:500:2::c */
{ U8("\x01""d""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x00\x00\x2d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0d") }, /* 2001:500:2d::d */
{ U8("\x01""f""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x00\x00\x2f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x0f") }, /* 2001:500:2f::f */
{ U8("\x01""h""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x53") }, /* 2001:500:1::53 */
{ U8("\x01""i""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x07\xfe\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x53") }, /* 2001:7fe::53 */
{ U8("\x01""j""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x03\x0c\x27\x00\x00\x00\x00\x00\x00\x00\x02\x00\x30") }, /* 2001:503:c27::2:30 */
{ U8("\x01""k""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x07\xfd\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x01") }, /* 2001:7fd::1 */
{ U8("\x01""l""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x05\x00\x00\x9f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x42") }, /* 2001:500:9f::42 */
{ U8("\x01""m""\x0c""root-servers""\x03""net"), I6, U8("\x20\x01\x0d\xc3\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x35") }, /* 2001:dc3::35 */
/* Initialize with SBELT name servers. */
#include "lib/root-hints.inc"
#define HINT_LEN_A sizeof(struct in_addr)
#define HINT_LEN_AAAA sizeof(struct in6_addr)
#define SBELT_LEN (sizeof(SBELT) / sizeof(SBELT[0]))
static const struct hint_info SBELT[] = {
#define HINT(name,type) { \
U8("\x01" #name "\x0c""root-servers""\x03""net"), \
HINT_LEN_##type, \
U8(HINT_##name##_##type), \
}
HINT(j, A),
HINT(k, A),
HINT(d, A),
HINT(e, A),
HINT(f, A),
HINT(g, A),
HINT(h, A),
HINT(i, A),
HINT(l, A),
HINT(m, A),
HINT(b, A),
HINT(c, A),
HINT(a, A),
HINT(a, AAAA),
HINT(b, AAAA),
HINT(c, AAAA),
HINT(d, AAAA),
HINT(e, AAAA),
HINT(f, AAAA),
HINT(g, AAAA),
HINT(h, AAAA),
HINT(i, AAAA),
HINT(j, AAAA),
HINT(k, AAAA),
HINT(l, AAAA),
HINT(m, AAAA),
#undef HINT
};
#undef I4
#undef I6
#undef HINT_LEN_A
#undef HINT_LEN_AAAA
static void update_cut_name(struct kr_zonecut *cut, const knot_dname_t *name)
......@@ -286,7 +296,7 @@ int kr_zonecut_set_sbelt(struct kr_context *ctx, struct kr_zonecut *cut)
ret = kr_zonecut_copy(cut, &ctx->root_hints);
} else {
/* Copy compiled-in root hints */
for (unsigned i = 0; i < HINT_COUNT; ++i) {
for (unsigned i = 0; i < SBELT_LEN; ++i) {
const struct hint_info *hint = &SBELT[i];
knot_rdata_init(rdata_arr, hint->len, hint->addr, 0);
ret = kr_zonecut_add(cut, hint->name, rdata_arr);
......
#!/bin/sh
echo "/* generated root hints */"
for atype in A AAAA; do
for n in a b c d e f g h i j k l m; do
ip="$(kdig "$atype" "$n.root-servers.net." +dnssec +short)"
ip_hex="$("$(dirname "$0")"/inet_pton.py "$ip")"
echo "#define HINT_${n}_${atype} \"$ip_hex\""
done
done
#!/usr/bin/python
#!/usr/bin/env python
from socket import inet_pton,AF_INET6
from socket import inet_pton,AF_INET6,AF_INET
import sys
from binascii import hexlify
from string import find
x = hexlify(inet_pton(AF_INET6, sys.argv[1]))
if find(sys.argv[1], ":") == -1:
addr_type = AF_INET
else:
addr_type = AF_INET6
x = hexlify(inet_pton(addr_type, sys.argv[1]))
out = ""
for i in range(0, 16):
for i in range(0, len(x) / 2):
out += "\\x" + x[i*2] + x[i*2+1]
print out
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment