Missing reverse zones are suggested for the private views' A and AAAA records (/24 for private IPv4, /32 for a public address, /48 for IPv6) and created filled with PTR records (jarl zone suggest-reverse, the Zones page). zone create --fill and zone fill-ptr add the PTRs a reverse zone lacks; a reverse zone created without a view goes to the private view using its addresses. Per zone, auto_ptr keeps the PTR records of A and AAAA records in step on every change (database version 12). Zone commands take a network. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"jarl/internal/auth"
|
|
"jarl/internal/engine"
|
|
)
|
|
|
|
// zoneFillPTR: POST /zones/{zone}/fill-ptr adds the PTR records a reverse
|
|
// zone lacks for its view's A and AAAA records (docs/reverse.md).
|
|
func (s *Server) zoneFillPTR(w http.ResponseWriter, r *http.Request, p *auth.Principal) error {
|
|
st, err := s.state(r)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
z, err := s.zoneByPath(r, st, p)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
return s.mutate(w, r, p, "", []engine.Request{engine.NewRequest(engine.OpZoneFillPTR, z.ID, engine.LinkInput{ZoneID: z.ID})}, nil)
|
|
}
|
|
|
|
// reverseSuggestions: GET /reverse-zones/suggestions lists the reverse
|
|
// zones the private views lack for their records' addresses.
|
|
func (s *Server) reverseSuggestions(w http.ResponseWriter, r *http.Request, p *auth.Principal) error {
|
|
st, err := s.state(r)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
out := []engine.ReverseSuggestion{}
|
|
for _, sg := range engine.ReverseSuggestions(st, s.eng.Exposures(st)) {
|
|
if p.CanSeeZone(sg.Zone+".", sg.View) {
|
|
out = append(out, sg)
|
|
}
|
|
}
|
|
writeJSON(w, http.StatusOK, out)
|
|
return nil
|
|
}
|