Commit 016e732e authored by Daniel Salzman's avatar Daniel Salzman

synth_record: fix empty default TTL and prefix

parent fbc2e64b
This diff is collapsed.
This diff is collapsed.
......@@ -53,7 +53,7 @@ int check_prefix(conf_check_t *args)
const yp_item_t scheme_mod_synth_record[] = {
{ C_ID, YP_TSTR, YP_VNONE },
{ MOD_TYPE, YP_TOPT, YP_VOPT = { synthetic_types, SYNTH_NULL } },
{ MOD_PREFIX, YP_TSTR, YP_VNONE, YP_FNONE, { check_prefix } },
{ MOD_PREFIX, YP_TSTR, YP_VSTR = { "" }, YP_FNONE, { check_prefix } },
{ MOD_ORIGIN, YP_TDNAME, YP_VNONE },
{ MOD_TTL, YP_TINT, YP_VINT = { 0, UINT32_MAX, 3600, YP_STIME } },
{ MOD_NET, YP_TDATA, YP_VDATA = { 0, NULL, addr_range_to_bin,
......@@ -73,15 +73,6 @@ int check_mod_synth_record(conf_check_t *args)
return KNOT_EINVAL;
}
// Check prefix.
conf_val_t prefix = conf_rawid_get_txn(args->conf, args->txn, C_MOD_SYNTH_RECORD,
MOD_PREFIX, args->previous->id,
args->previous->id_len);
if (prefix.code != KNOT_EOK) {
*args->err_str = "no owner prefix specified";
return KNOT_EINVAL;
}
// Check origin.
conf_val_t origin = conf_rawid_get_txn(args->conf, args->txn, C_MOD_SYNTH_RECORD,
MOD_ORIGIN, args->previous->id,
......@@ -95,15 +86,6 @@ int check_mod_synth_record(conf_check_t *args)
return KNOT_EINVAL;
}
// Check ttl.
conf_val_t ttl = conf_rawid_get_txn(args->conf, args->txn, C_MOD_SYNTH_RECORD,
MOD_TTL, args->previous->id,
args->previous->id_len);
if (ttl.code != KNOT_EOK) {
*args->err_str = "no ttl specified";
return KNOT_EINVAL;
}
// Check network subnet.
conf_val_t net = conf_rawid_get_txn(args->conf, args->txn, C_MOD_SYNTH_RECORD,
MOD_NET, args->previous->id,
......
$ORIGIN forward.
$TTL 3600
$TTL 7200
@ SOA dns1 hostmaster 2010111213 10800 3600 1209600 7200
NS dns1
......
......@@ -28,6 +28,7 @@ for z in zone:
knot.gen_key(z, alg="RSASHA256")
# Configure 'synth_record' modules for auto forward/reverse zones
knot.add_module(zone[FWD], ModSynthRecord("forward", None, None, "192.168.0.1"))
knot.add_module(zone[FWD], ModSynthRecord("forward", "dynamic4-", "900", "192.168.1.0-192.168.1.127"))
knot.add_module(zone[FWD], ModSynthRecord("forward", "dynamic6-", "900", "2620:0:b61::/52"))
knot.add_module(zone[REV4], ModSynthRecord("reverse", "dynamic4-", "900", "192.168.1.0/25", "forward."))
......@@ -42,33 +43,37 @@ static_map = [ ("192.168.1.42", "42." + zone[REV4].name, "static4-a.forward."),
# Check static reverse records
for (_, reverse, forward) in static_map:
resp = knot.dig(reverse, "PTR", dnssec=True)
resp.check(forward, rcode="NOERROR", flags="QR AA")
resp.check(forward, rcode="NOERROR", flags="QR AA", ttl=172800)
# Check static forward records
for (addr, reverse, forward) in static_map:
rrtype = "AAAA" if ":" in addr else "A"
resp = knot.dig(forward, rrtype, dnssec=True)
resp.check(addr, rcode="NOERROR", flags="QR AA")
resp.check(addr, rcode="NOERROR", flags="QR AA", ttl=7200)
# Check positive dynamic reverse records
dynamic_map = [ ("192.168.1.1", "1." + zone[REV4].name, "dynamic4-192-168-1-1." + zone[FWD].name),
("2620:0:b61::1", "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0." + zone[REV6].name, "dynamic6-2620-0000-0b61-0000-0000-0000-0000-0001." + zone[FWD].name) ]
for (_, reverse, forward) in dynamic_map:
resp = knot.dig(reverse, "PTR", dnssec=True)
resp.check(forward, rcode="NOERROR", flags="QR AA")
resp.check(forward, rcode="NOERROR", flags="QR AA", ttl=900)
# Check positive dynamic forward records (default TTL and prefix)
resp = knot.dig("192-168-0-1.forward", "A", dnssec=True)
resp.check("192.168.0.1", rcode="NOERROR", ttl=3600)
# Check positive dynamic forward records
for (addr, reverse, forward) in dynamic_map:
rrtype = "AAAA" if ":" in addr else "A"
resp = knot.dig(forward, rrtype, dnssec=True)
resp.check(addr, rcode="NOERROR", flags="QR AA")
resp.check(addr, rcode="NOERROR", flags="QR AA", ttl=900)
# Check NODATA answer for all records
for (addr, reverse, forward) in dynamic_map:
resp = knot.dig(reverse, "TXT")
resp.check(nordata=forward, rcode="NOERROR", flags="QR AA")
resp.check(nordata=forward, rcode="NOERROR", flags="QR AA", ttl=172800)
resp = knot.dig(forward, "TXT")
resp.check(nordata=addr, rcode="NOERROR", flags="QR AA")
resp.check(nordata=addr, rcode="NOERROR", flags="QR AA", ttl=172800)
# Check for SERVFAIL with DNSSEC - no way to prove
resp = knot.dig(reverse, "TXT", dnssec=True)
......@@ -92,7 +97,7 @@ alias_map = [ ("192.168.1.1", None, "cname4." + zone[FWD].name),
for (addr, _, forward) in alias_map:
rrtype = "AAAA" if ":" in addr else "A"
resp = knot.dig(forward, rrtype, dnssec=True)
resp.check(addr, rcode="NOERROR", flags="QR AA")
resp.check(addr, rcode="NOERROR", flags="QR AA", ttl=900)
# Check ANY type question
for (addr, reverse, forward) in dynamic_map:
......
......@@ -63,7 +63,9 @@ class ModSynthRecord(KnotModule):
conf.begin(self.conf_name)
conf.id_item("id", self.conf_id)
conf.item_str("type", self.mtype)
if (self.prefix):
conf.item_str("prefix", self.prefix)
if (self.ttl):
conf.item_str("ttl", self.ttl)
conf.item_str("network", self.network)
if (self.origin):
......
Markdown is supported
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