tags: Tags to link with other policy rules.
ttl: Default TTL value used for added local subtree.
nodata: Use NODATA synthesis. NODATA will be synthesised for matching name, but mismatching type(e.g. AAAA query when only A exists).
- addresses: Subtree addresses.
roots: Subtree roots.
- roots_file: Subtree roots from given file.
- roots_url: Subtree roots form given URL.
- refresh: Refresh time to update data from 'roots-file' or 'roots-url'.
"""
+ # addresses: Subtree addresses.
+ # roots_file: Subtree roots from given file.
+ # roots_url: Subtree roots form given URL.
+ # refresh: Refresh time to update data from 'roots-file' or 'roots-url'.
+
type: Literal["empty", "nxdomain", "redirect"]
tags: Optional[List[IDPattern]] = None
ttl: Optional[TimeUnit] = None
nodata: bool = True
- addresses: Optional[List[IPAddress]] = None
roots: Optional[List[DomainName]] = None
- roots_file: Optional[File] = None
- roots_url: Optional[EscapedStr] = None
- refresh: Optional[TimeUnit] = None
+ # # These aren't implemented yet.
+ # addresses: Optional[List[IPAddress]] = None
+ # roots_file: Optional[File] = None
+ # roots_url: Optional[EscapedStr] = None
+ # refresh: Optional[TimeUnit] = None
+
+ # def _validate(self) -> None:
+ # options_sum = sum([bool(self.roots), bool(self.roots_file), bool(self.roots_url)])
+ # if options_sum > 1:
+ # raise ValueError("only one of, 'roots', 'roots-file' or 'roots-url' can be configured")
+ # elif options_sum < 1:
+ # raise ValueError("one of, 'roots', 'roots-file' or 'roots-url' must be configured")
+ # if self.refresh and not (self.roots_file or self.roots_url):
+ # raise ValueError("'refresh' can be only configured with 'roots-file' or 'roots-url'")
def _validate(self) -> None:
- options_sum = sum([bool(self.roots), bool(self.roots_file), bool(self.roots_url)])
- if options_sum > 1:
- raise ValueError("only one of, 'roots', 'roots-file' or 'roots-url' can be configured")
- elif options_sum < 1:
- raise ValueError("one of, 'roots', 'roots-file' or 'roots-url' must be configured")
- if self.refresh and not (self.roots_file or self.roots_url):
- raise ValueError("'refresh' can be only configured with 'roots-file' or 'roots-url'")
+ if self.roots is None:
+ raise ValueError("'roots' is missing")
class RPZSchema(ConfigSchema):
"val",
[
{"type": "empty", "roots": ["sub2.example.org"]},
- {"type": "empty", "roots-url": "https://example.org/blocklist.txt", "refresh": "1d"},
- {"type": "nxdomain", "roots-file": "/etc/hosts"}, # must be an existing file or validation will fail
- {"type": "redirect", "roots": ["sub4.example.org"], "addresses": ["127.0.0.1", "::1"]},
+ {"type": "nxdomain", "roots": ["sub3.example.org", "sub5.example.net."], "ttl": "1h"},
+ # {"type": "empty", "roots-url": "https://example.org/blocklist.txt", "refresh": "1d"},
+ # {"type": "nxdomain", "roots-file": "/etc/hosts"}, # must be an existing file or validation will fail
+ {"type": "redirect", "roots": ["sub4.example.org"]},
],
)
def test_subtree_valid(val: Any):