aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBernd Fix <brf@hoi-polloi.org>2022-11-11 11:56:38 +0100
committerBernd Fix <brf@hoi-polloi.org>2022-11-11 11:56:38 +0100
commit1a7284815bb2a63aac6b726e9167baed4813aa95 (patch)
tree61167ffda209383178df364fa27479ff660f54dc
parent30f8a148ff551129b3ccc8f52e5dda1ec2104ee3 (diff)
downloadgnunet-go-1a7284815bb2a63aac6b726e9167baed4813aa95.tar.gz
gnunet-go-1a7284815bb2a63aac6b726e9167baed4813aa95.zip
Plugin integration (ZoneMaster)v0.1.39
-rw-r--r--src/gnunet/service/gns/rr/coexist.go7
-rw-r--r--src/gnunet/service/zonemaster/gui.go34
2 files changed, 31 insertions, 10 deletions
diff --git a/src/gnunet/service/gns/rr/coexist.go b/src/gnunet/service/gns/rr/coexist.go
index 1037b11..10c595a 100644
--- a/src/gnunet/service/gns/rr/coexist.go
+++ b/src/gnunet/service/gns/rr/coexist.go
@@ -56,8 +56,13 @@ func CanCoexist(t enums.GNSType, list []*enums.GNSSpec, label string) (ok bool,
56 Flags: forced, 56 Flags: forced,
57 } 57 }
58 for i, e := range testList { 58 for i, e := range testList {
59 // skip unknown types
60 if rr = NilRR(e.Type); rr == nil {
61 return true, 0
62 }
63 // check replacement
59 testList[i] = eNew 64 testList[i] = eNew
60 ok, forced = NilRR(e.Type).Coexist(testList, label) 65 ok, forced = rr.Coexist(testList, label)
61 if !ok { 66 if !ok {
62 return 67 return
63 } 68 }
diff --git a/src/gnunet/service/zonemaster/gui.go b/src/gnunet/service/zonemaster/gui.go
index 0442fbf..9489130 100644
--- a/src/gnunet/service/zonemaster/gui.go
+++ b/src/gnunet/service/zonemaster/gui.go
@@ -625,15 +625,23 @@ func (zm *ZoneMaster) editRec(w http.ResponseWriter, r *http.Request, data *NewE
625 if rec, err = zm.zdb.GetRecord(data.Ref); err != nil { 625 if rec, err = zm.zdb.GetRecord(data.Ref); err != nil {
626 return 626 return
627 } 627 }
628 // default GUI dialog template name
629 dialog := "edit_rec"
630
631 // get possible plugin handler
632 plugin, ok := zm.hdlrs[rec.RType]
633 if ok {
634 // get custom edit dialog
635 _, dialog = plugin.TemplateNames()
636 }
628 // get prefix used for attributes and fields 637 // get prefix used for attributes and fields
629 pf, ok := dlgPrefix[rec.RType] 638 pf, ok := dlgPrefix[rec.RType]
630 if !ok { 639 if !ok {
631 // no prefix defined; ask plugin 640 // no prefix defined; ask plugin
632 inst, ok := zm.hdlrs[rec.RType] 641 if plugin == nil {
633 if !ok {
634 return errors.New("no prefix defined for record type") 642 return errors.New("no prefix defined for record type")
635 } 643 }
636 pf = inst.Prefix(uint32(rec.RType)) + "_" 644 pf = plugin.Prefix(uint32(rec.RType)) + "_"
637 } 645 }
638 646
639 // save shared attributes 647 // save shared attributes
@@ -665,14 +673,22 @@ func (zm *ZoneMaster) editRec(w http.ResponseWriter, r *http.Request, data *NewE
665 if rec.Flags&enums.GNS_FLAG_CRITICAL != 0 { 673 if rec.Flags&enums.GNS_FLAG_CRITICAL != 0 {
666 data.Params[pf+"critical"] = "on" 674 data.Params[pf+"critical"] = "on"
667 } 675 }
668 // get record instance 676 // set record attributes
669 var inst rr.RR 677 if plugin != nil {
670 if inst, err = rr.ParseRR(rec.RType, rec.Data); err == nil { 678 var params map[string]string
671 // add RR attributes to list 679 params, err = plugin.ToMap(uint32(rec.RType), rec.Data)
672 inst.ToMap(data.Params, pf) 680 for k, v := range params {
681 data.Params[k] = v
682 }
683 } else {
684 var inst rr.RR
685 if inst, err = rr.ParseRR(rec.RType, rec.Data); err == nil {
686 // add RR attributes to list
687 inst.ToMap(data.Params, pf)
688 }
673 } 689 }
674 // show dialog 690 // show dialog
675 renderPage(w, data, "edit_rec") 691 renderPage(w, data, dialog)
676 return 692 return
677} 693}
678 694