Skip to content

Commit

Permalink
adds deleteName (all RRsets) to JS API
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-burns committed Jul 10, 2024
1 parent ef657ae commit 9853216
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 2 deletions.
18 changes: 18 additions & 0 deletions golang/sig0/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ func (signer *Signer) RemoveRRset(rr dns.RR) error {
return nil
}

func (signer *Signer) RemoveParsedName(rr string) error {
rrRemove, err := dns.NewRR(rr)
if err != nil {
return fmt.Errorf("sig0: failed to parse RR: %w", err)
}

return signer.RemoveName(rrRemove)
}

func (signer *Signer) RemoveName(rr dns.RR) error {
if signer.update == nil {
return fmt.Errorf("no update in progress")
}

signer.update.RemoveName([]dns.RR{rr})
return nil
}

// UpdateA is a convenience function to update an A record.
// Need to call StartUpdate first, then UpdateA for each record to update, then SignUpdate.
func (signer *Signer) UpdateA(subZone, zone, addr string) error {
Expand Down
18 changes: 16 additions & 2 deletions golang/wasm/wrapper_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ func newUpdater(_ js.Value, args []js.Value) any {
}),

// deleteRR
// deletes a single RR
// deletes a single RR, see RFC 2136 section 2.5.4
// 1 argument: the RR string
// returns null or an error string
"deleteRR": js.FuncOf(func(this js.Value, args []js.Value) any {
Expand All @@ -164,7 +164,7 @@ func newUpdater(_ js.Value, args []js.Value) any {
}),

// deleteRRset
// deletes a RRset
// deletes a RRset see RFC 2136 section 2.5.2.
// 1 argument: the RR string without RRdata
// returns null or an error string
"deleteRRset": js.FuncOf(func(this js.Value, args []js.Value) any {
Expand All @@ -176,6 +176,20 @@ func newUpdater(_ js.Value, args []js.Value) any {
return js.Null()
}),

// deleteName
// deletes all RRsets for a given name or FQDN, see RFC 2136 section 2.5.2.
// *WARNING* - use with care, as this deletes *all* RRsets, including KEYs!
// 1 argument: the RR string without RRdata
// returns null or an error string
"deleteName": js.FuncOf(func(this js.Value, args []js.Value) any {
rr := args[0].String()
err := signer.RemoveParsedName(rr)
if err != nil {
return err.Error()
}
return js.Null()
}),

// send signed update
// no arguments
// returns a promise
Expand Down

0 comments on commit 9853216

Please sign in to comment.