Address ranges in address match lists (IPv4 and IPv6)
ACLs, views' match lists, options with address match lists and blocking client groups take ranges such as 10.0.10.101-10.0.10.199 or 2001:db8::100-2001:db8::1ff (negated, or with spaces around the dash, too). Jarl stores the range as written and writes the fewest prefixes that cover exactly that range to named.conf, with the range as a comment. New package internal/iprange; namedconf gets an AMRange element (a range used to parse as an ACL name), ExpandRanges and statement comments. Mistakes are refused when entered, validation sees what ranges cover, and IPv6 ranges in the IPv4-mapped space get a warning. The web UI shows what a range becomes while typing (GET /catalog/ranges). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
49b1c872c9
commit
e2e5007f94
32 files changed
+905
-31
No files matched your search
@@ -13,6 +13,7 @@ import (
|
||||
"jarl/internal/catalog"
|
||||
"jarl/internal/dnsname"
|
||||
"jarl/internal/engine"
|
||||
"jarl/internal/iprange"
|
||||
"jarl/internal/model"
|
||||
"jarl/internal/render"
|
||||
"jarl/internal/rr"
|
||||
@@ -554,6 +555,42 @@ func (s *Server) catalogRRTypes(w http.ResponseWriter, r *http.Request, p *auth.
|
||||
return nil
|
||||
}
|
||||
|
||||
// catalogRanges: GET /catalog/ranges?r=A-B,C-D shows the prefixes each
|
||||
// address range is written to named.conf as (the web UI shows them while
|
||||
// you type). Text that isn't a range is left out; a range with a mistake
|
||||
// comes back with its error.
|
||||
func (s *Server) catalogRanges(w http.ResponseWriter, r *http.Request, p *auth.Principal) error {
|
||||
type rangeInfo struct {
|
||||
Input string `json:"input"`
|
||||
Range string `json:"range,omitempty"`
|
||||
Prefixes []string `json:"prefixes,omitempty"`
|
||||
Size string `json:"size,omitempty"`
|
||||
Error string `json:"error,omitempty"`
|
||||
}
|
||||
out := []rangeInfo{}
|
||||
for _, in := range strings.Split(r.URL.Query().Get("r"), ",") {
|
||||
in = strings.TrimSpace(in)
|
||||
if in == "" || len(out) >= 100 {
|
||||
continue
|
||||
}
|
||||
rg, ok, err := iprange.Parse(strings.TrimSpace(strings.TrimPrefix(in, "!")))
|
||||
switch {
|
||||
case !ok:
|
||||
continue
|
||||
case err != nil:
|
||||
out = append(out, rangeInfo{Input: in, Error: err.Error()})
|
||||
default:
|
||||
ri := rangeInfo{Input: in, Range: rg.String(), Size: rg.SizeText()}
|
||||
for _, pf := range rg.Prefixes() {
|
||||
ri.Prefixes = append(ri.Prefixes, pf.String())
|
||||
}
|
||||
out = append(out, ri)
|
||||
}
|
||||
}
|
||||
writeJSON(w, http.StatusOK, out)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (s *Server) catalogGrants(w http.ResponseWriter, r *http.Request, p *auth.Principal) error {
|
||||
roles := map[string][]string{}
|
||||
for name, gs := range auth.RoleTemplates {
|
||||
|
||||
Reference in new issue
Block a user