Add AddressOverride and DomainRule objects for what lived in a ConfigMap and the config file
The address redirects page rewrote an RPZ ConfigMap through the resolver's own service account, and the domains page rewrote allow_entries/block_entries in the config file. Both become cluster objects like the rest. AddressOverride is one name answered with fixed addresses (the name and everything under it), exactly what an RPZ "name A address" line did. DomainRule is a block or allow list of inline names. The resolver reads both with the existing watch: overrides are rendered into the managed RPZ source the blocklist manager already has, and rule names join the config's inline entries in the merged overlay, so the file's config is never written to. Names are checked to be DNS names or wildcard patterns before they are used, because they are joined into line-oriented parser input and a newline or a comment character in one would otherwise add a rule of its own. The console edits both: the address-overrides and domains endpoints now write objects. The console keeps its added rules in one DomainRule per action (inline-block, inline-allow) instead of an object per name, and removes a name from whichever DomainRule holds it, wildcard or not. An end-to-end test drives the pages' endpoints and checks the resolver's answers. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
7fd6a7e7a5
commit
88479b9a12
19 files changed
+912
-18
No files matched your search
@@ -21,11 +21,12 @@ const (
|
||||
|
||||
// The resources the runtime watches.
|
||||
var (
|
||||
ZoneGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "dnszones"}
|
||||
GroupGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "clientgroups"}
|
||||
ListGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "blocklists"}
|
||||
allGVRs = []schema.GroupVersionResource{ZoneGVR, GroupGVR, ListGVR}
|
||||
kindNames = map[string]string{ZoneGVR.Resource: "DNSZone", GroupGVR.Resource: "ClientGroup", ListGVR.Resource: "BlockList"}
|
||||
ZoneGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "dnszones"}
|
||||
GroupGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "clientgroups"}
|
||||
ListGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "blocklists"}
|
||||
OverrideGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "addressoverrides"}
|
||||
RuleGVR = schema.GroupVersionResource{Group: APIGroup, Version: Version, Resource: "domainrules"}
|
||||
allGVRs = []schema.GroupVersionResource{ZoneGVR, GroupGVR, ListGVR, OverrideGVR, RuleGVR}
|
||||
)
|
||||
|
||||
// DNSZoneSpec declares one authoritative zone. The zone's name is spec.zone,
|
||||
@@ -81,3 +82,24 @@ type BlockListSpec struct {
|
||||
Comment string `json:"comment,omitempty"`
|
||||
InsecureSkipTLSVerify bool `json:"insecure_skip_tls_verify,omitempty"`
|
||||
}
|
||||
|
||||
// AddressOverrideSpec answers a name, and everything under it, with fixed
|
||||
// addresses instead of asking upstream: "tornberg.me -> 10.10.3.10" for split
|
||||
// horizon DNS. It is what an RPZ "name A address" line does, one object per
|
||||
// name.
|
||||
type AddressOverrideSpec struct {
|
||||
Domain string `json:"domain"`
|
||||
// Addresses are IPv4 and IPv6 literals; each becomes an A or AAAA answer.
|
||||
Addresses []string `json:"addresses"`
|
||||
}
|
||||
|
||||
// DomainRuleSpec is an inline allow or block rule list, the objects behind the
|
||||
// console's Domains page. A name may carry a wildcard prefix: "*.example.com"
|
||||
// is the subdomains, "**.example.com" the name and its subdomains.
|
||||
type DomainRuleSpec struct {
|
||||
// Action is "block" or "allow". An allow rule rescues a name that any
|
||||
// blocklist would block.
|
||||
Action string `json:"action"`
|
||||
Names []string `json:"names"`
|
||||
Comment string `json:"comment,omitempty"`
|
||||
}
|
||||
Reference in new issue
Block a user