Skip to content

Commit 115c11b

Browse files
committed
datamodel: stabilize dns64 schema
1 parent b06cc25 commit 115c11b

File tree

6 files changed

+64
-53
lines changed

6 files changed

+64
-53
lines changed

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ Incompatible changes
2424
- /workers-max
2525
- Renamed/moved options in the declarative configuration model (YAML).
2626
- /network/tls/files-watchdog -> /network/tls/watchdog
27+
- /dns64: true -> /dns64/enabled: true
28+
- /dns64/rev-ttl -> /dns64/reverse-ttl
2729
- /dnssec/keep-removed -> /dnssec/trust-anchors-keep-removed
2830
- /dnssec/trust-anchor-sentinel -> /dnssec/sentinel
2931
- /dnssec/trust-anchor-signal-query -> /dnssec/signal-query

doc/_static/config.schema.json

Lines changed: 38 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1309,44 +1309,46 @@
13091309
}
13101310
},
13111311
"dns64": {
1312-
"anyOf": [
1313-
{
1314-
"type": "boolean"
1312+
"description": "DNS64 (RFC 6147) configuration.",
1313+
"type": "object",
1314+
"properties": {
1315+
"enabled": {
1316+
"type": "boolean",
1317+
"description": "Enable/disable DNS64.",
1318+
"default": false
13151319
},
1316-
{
1317-
"description": "DNS64 (RFC 6147) configuration.",
1318-
"type": "object",
1319-
"properties": {
1320-
"prefix": {
1321-
"type": "string",
1322-
"description": "IPv6 prefix to be used for synthesizing AAAA records.",
1323-
"default": "64:ff9b::/96"
1324-
},
1325-
"rev-ttl": {
1326-
"type": [
1327-
"string",
1328-
"null"
1329-
],
1330-
"pattern": "^(\\d+)(us|ms|s|m|h|d)$",
1331-
"description": "TTL in CNAME generated in the reverse 'ip6.arpa.' subtree.",
1332-
"default": null
1333-
},
1334-
"exclude-subnets": {
1335-
"type": [
1336-
"array",
1337-
"null"
1338-
],
1339-
"items": {
1340-
"type": "string"
1341-
},
1342-
"description": "IPv6 subnets that are disallowed in answer.",
1343-
"default": null
1344-
}
1345-
}
1320+
"prefix": {
1321+
"type": "string",
1322+
"description": "IPv6 prefix to be used for synthesizing AAAA records.",
1323+
"default": "64:ff9b::/96"
1324+
},
1325+
"reverse-ttl": {
1326+
"type": [
1327+
"string",
1328+
"null"
1329+
],
1330+
"pattern": "^(\\d+)(us|ms|s|m|h|d)$",
1331+
"description": "TTL in CNAME generated in the reverse 'ip6.arpa.' subtree.",
1332+
"default": null
1333+
},
1334+
"exclude-subnets": {
1335+
"type": [
1336+
"array",
1337+
"null"
1338+
],
1339+
"items": {
1340+
"type": "string"
1341+
},
1342+
"description": "IPv6 subnets that are disallowed in answer.",
1343+
"default": null
13461344
}
1347-
],
1348-
"description": "Disable DNS64 (RFC 6147), enable with defaults or set new configuration.",
1349-
"default": false
1345+
},
1346+
"default": {
1347+
"enabled": false,
1348+
"prefix": "64:ff9b::/96",
1349+
"reverse_ttl": null,
1350+
"exclude_subnets": null
1351+
}
13501352
},
13511353
"logging": {
13521354
"description": "Logging and debugging configuration.",

python/knot_resolver/datamodel/config_schema.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ class Raw(ConfigSchema):
101101
forward: List of Forward Zones and its configuration.
102102
cache: DNS resolver cache configuration.
103103
dnssec: DNSSEC configuration.
104-
dns64: Disable DNS64 (RFC 6147), enable with defaults or set new configuration.
104+
dns64: DNS64 (RFC 6147) configuration.
105105
logging: Logging and debugging configuration.
106106
monitoring: Metrics exposisition configuration (Prometheus, Graphite)
107107
lua: Custom Lua configuration.
@@ -122,7 +122,7 @@ class Raw(ConfigSchema):
122122
forward: Optional[List[ForwardSchema]] = None
123123
cache: CacheSchema = lazy_default(CacheSchema, {})
124124
dnssec: DnssecSchema = DnssecSchema()
125-
dns64: Union[bool, Dns64Schema] = False
125+
dns64: Dns64Schema = Dns64Schema()
126126
logging: LoggingSchema = LoggingSchema()
127127
monitoring: MonitoringSchema = MonitoringSchema()
128128
rate_limiting: Optional[RateLimitingSchema] = None
@@ -143,7 +143,7 @@ class Raw(ConfigSchema):
143143
forward: Optional[List[ForwardSchema]]
144144
cache: CacheSchema
145145
dnssec: DnssecSchema
146-
dns64: Union[Literal[False], Dns64Schema]
146+
dns64: Dns64Schema
147147
logging: LoggingSchema
148148
monitoring: MonitoringSchema
149149
rate_limiting: Optional[RateLimitingSchema]
@@ -166,11 +166,6 @@ def _workers(self, obj: Raw) -> Any:
166166
)
167167
return obj.workers
168168

169-
def _dns64(self, obj: Raw) -> Any:
170-
if obj.dns64 is True:
171-
return Dns64Schema()
172-
return obj.dns64
173-
174169
def _validate(self) -> None:
175170
# warn about '/management/unix-socket' not located in '/rundir'
176171
if self.management.unix_socket and self.management.unix_socket.to_path().parent != self.rundir.to_path():

python/knot_resolver/datamodel/dns64_schema.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,13 @@ class Dns64Schema(ConfigSchema):
99
DNS64 (RFC 6147) configuration.
1010
1111
---
12+
enabled: Enable/disable DNS64.
1213
prefix: IPv6 prefix to be used for synthesizing AAAA records.
13-
rev_ttl: TTL in CNAME generated in the reverse 'ip6.arpa.' subtree.
14+
reverse_ttl: TTL in CNAME generated in the reverse 'ip6.arpa.' subtree.
1415
exclude_subnets: IPv6 subnets that are disallowed in answer.
1516
"""
1617

18+
enabled: bool = False
1719
prefix: IPv6Network96 = IPv6Network96("64:ff9b::/96")
18-
rev_ttl: Optional[TimeUnit] = None
20+
reverse_ttl: Optional[TimeUnit] = None
1921
exclude_subnets: Optional[List[IPv6Network]] = None
Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
11
{% from 'macros/common_macros.lua.j2' import string_table %}
22

3-
{% if cfg.dns64 %}
4-
-- load dns64 module
3+
{% if cfg.dns64.enabled %}
4+
5+
-- Enable DNS64 by loading module
56
modules.load('dns64')
67

7-
-- dns64.prefix
8+
-- Configure DNS64 module
89
dns64.config({
910
prefix = '{{ cfg.dns64.prefix.to_std().network_address|string }}',
10-
{% if cfg.dns64.rev_ttl %}
11-
rev_ttl = {{ cfg.dns64.rev_ttl.seconds() }},
11+
{% if cfg.dns64.reverse_ttl %}
12+
rev_ttl = {{ cfg.dns64.reverse_ttl.seconds() }},
1213
{% endif %}
1314
{% if cfg.dns64.exclude_subnets %}
1415
exclude_subnets = {{ string_table(cfg.dns64.exclude_subnets) }},
1516
{% endif %}
1617
})
18+
19+
{% else %}
20+
21+
-- Disable DNS64 by unloading module
22+
-- modules.unload('dns64')
23+
1724
{% endif %}

tests/manager/datamodel/test_config_schema.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def test_config_defaults():
5050
config = KresConfig()
5151

5252
# DNS64 default
53-
assert config.dns64 == False
53+
assert config.dns64.enabled == False
5454

5555

5656
def test_dnssec_false():
@@ -73,7 +73,10 @@ def test_dnssec_default_true():
7373

7474

7575
def test_dns64_prefix_default():
76-
assert str(KresConfig({"dns64": True}).dns64.prefix) == "64:ff9b::/96"
76+
config = KresConfig({ "dns64": { "enabled": True } })
77+
78+
assert config.dns64.enabled == True
79+
assert str(config.dns64.prefix) == "64:ff9b::/96"
7780

7881

7982
def test_config_json_schema():

0 commit comments

Comments
 (0)