Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adds wasm deleteRR & support in sig0 #32

Merged
merged 1 commit into from
Jul 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions golang/sig0/update.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,24 @@ func (signer *Signer) UpdateRR(rr dns.RR) error {
return nil
}

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

return signer.RemoveRR(rrRemove)
}

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

signer.update.Remove([]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
9 changes: 9 additions & 0 deletions golang/wasm/wrapper_js.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,15 @@ func newUpdater(_ js.Value, args []js.Value) any {
return js.Null()
}),

"deleteRR": js.FuncOf(func(this js.Value, args []js.Value) any {
rr := args[0].String()
err := signer.RemoveParsedRR(rr)
if err != nil {
return err.Error()
}
return js.Null()
}),

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