gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[gnunet-go-plugins] 01/01: Initial revision.


From: gnunet
Subject: [gnunet-go-plugins] 01/01: Initial revision.
Date: Fri, 28 Oct 2022 18:01:48 +0200

This is an automated email from the git hooks/post-receive script.

bernd-fix pushed a commit to branch master
in repository gnunet-go-plugins.

commit 2e57022ed46b2fac41c4676da467b0cbdb6ed712
Author: Bernd Fix <brf@hoi-polloi.org>
AuthorDate: Fri Oct 28 17:58:21 2022 +0200

    Initial revision.
---
 AUTHORS            |   1 +
 Makefile           |  29 +++++++++++++++
 go.mod             |   3 ++
 go.sum             |   0
 reclaimid/Makefile |  30 +++++++++++++++
 reclaimid/gui.htpl |  37 +++++++++++++++++++
 reclaimid/main.go  | 106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 7 files changed, 206 insertions(+)

diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..3006973
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Bernd Fix   <brf@hoi-polloi.org>    >Y<
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..28cb5fe
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,29 @@
+# This file is part of gnunet-go-plugins, a collection of plugins for
+# the GNUnet-implementation in Golang (gnunet.go). Plugins are used to
+# implement type-specific processing of resource records (e.g. GUI).
+# Copyright (C) 2022 by the authors:
+#
+# * Bernd Fix <brf@hoi-polloi.org>  >Y<
+#
+# gnunet-go-plugins is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License,
+# or (at your option) any later version.
+#
+# gnunet-go is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# SPDX-License-Identifier: AGPL3.0-or-later
+
+SUBDIRS = reclaimid
+
+all:
+       @for i in $(SUBDIRS); do (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) 
all); done
+
+clean:
+       @for i in $(SUBDIRS); do (cd $$i; $(MAKE) $(MFLAGS) $(MYMAKEFLAGS) 
clean); done
diff --git a/go.mod b/go.mod
new file mode 100644
index 0000000..dbcb388
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,3 @@
+module plugins
+
+go 1.19
diff --git a/go.sum b/go.sum
new file mode 100644
index 0000000..e69de29
diff --git a/reclaimid/Makefile b/reclaimid/Makefile
new file mode 100644
index 0000000..acd9ae1
--- /dev/null
+++ b/reclaimid/Makefile
@@ -0,0 +1,30 @@
+# This file is part of gnunet-go-plugins, a collection of plugins for
+# the GNUnet-implementation in Golang (gnunet.go). Plugins are used to
+# implement type-specific processing of resource records (e.g. GUI).
+# Copyright (C) 2022 by the authors:
+#
+# * Bernd Fix <brf@hoi-polloi.org>  >Y<
+#
+# gnunet-go-plugins is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License,
+# or (at your option) any later version.
+#
+# gnunet-go is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# SPDX-License-Identifier: AGPL3.0-or-later
+
+
+all: ${GOPATH}/bin/plugin_reclaimid.so
+
+clean: ${GOPATH}/bin/plugin_reclaimid.so
+       rm -f $^
+
+${GOPATH}/bin/plugin_reclaimid.so: main.go gui.htpl
+       go build -buildmode=plugin -gcflags="-N -l" -o $@ ./...
diff --git a/reclaimid/gui.htpl b/reclaimid/gui.htpl
new file mode 100644
index 0000000..2a8f5d8
--- /dev/null
+++ b/reclaimid/gui.htpl
@@ -0,0 +1,37 @@
+{{define "new_reclaim"}}
+    <h3>New Reclaim:ID resource record</h3>
+    <div>
+       <p>Ref = {{.Ref}}</p>
+           <p>Action = {{.Action}}</p>
+           <p>Button = {{.Button}}</p>
+        <p>Names: {{range $i,$v := .Names}}'{{$v}}',{{end}}</p>
+        <p>RRSpecs:</p>
+        <ul>
+            {{range $i,$s := .RRspecs}}
+            <li>Type = {{$s.Type}}, Flags = {{$s.Flags}}</li>
+            {{end}}
+        </ul>
+        <p>Params:</p>
+        <ul>
+        {{range $k,$v := .Params}}
+            <li>'{{$k}}' = '{{$v}}'</li>
+        {{end}}
+        </ul>
+    </div>
+    <a href="/"><button>Leave</button></a>
+{{end}}
+{{define "edit_reclaim"}}
+    <h3>Edit Reclaim:ID resource record</h3>
+    <div>
+       <p>Ref = {{.Ref}}</p>
+           <p>Action = {{.Action}}</p>
+           <p>Button = {{.Button}}</p>
+        <p>Names: {{range $i,$v := .Names}}'{{$v}}',{{end}}</p>
+        <ul>
+        {{range $k,$v := .Params}}
+            <li>'{{$k}}' = '{{$v}}'</li>
+        {{end}}
+        </ul>
+    </div>
+    <a href="/"><button>Leave</button></a>
+{{end}}
diff --git a/reclaimid/main.go b/reclaimid/main.go
new file mode 100644
index 0000000..f42aa22
--- /dev/null
+++ b/reclaimid/main.go
@@ -0,0 +1,106 @@
+// This file is part of gnunet-go-plugins, a collection of plugins for
+// the GNUnet-implementation in Golang (gnunet.go). Plugins are used to
+// implement type-specific processing of resource records (e.g. GUI).
+// Copyright (C) 2022 by the authors:
+//
+// * Bernd Fix <brf@hoi-polloi.org>  >Y<
+//
+// gnunet-go-plugins is free software: you can redistribute it and/or modify
+// it under the terms of the GNU Affero General Public License as published
+// by the Free Software Foundation, either version 3 of the License,
+// or (at your option) any later version.
+//
+// gnunet-go is distributed in the hope that it will be useful, but
+// WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+// Affero General Public License for more details.
+//
+// You should have received a copy of the GNU Affero General Public License
+// along with this program.  If not, see <http://www.gnu.org/licenses/>.
+//
+// SPDX-License-Identifier: AGPL3.0-or-later
+
+package main
+
+import (
+       _ "embed"
+)
+
+// List of handled resource record types with associated identifier.
+// The identifiers MUST be derived from stripped enums.GNSType strings
+// and must be used as template names.
+var handledTypes = map[uint32]string{
+       65544: "RECLAIM_ATTRIBUTE",
+       65545: "RECLAIM_TICKET",
+       65550: "RECLAIM_ATTRIBUTE_REF",
+       65552: "RECLAIM_OIDC_CLIENT",
+       65553: "RECLAIM_OIDC_REDIRECT",
+       65554: "RECLAIM_CREDENTIAL",
+       65555: "RECLAIM_PRESENTATION",
+}
+
+// Plugin is the instance of a custom implementation accessed by the
+// gnunet-go framework
+//
+//nolint:deadcode // used by framework
+var Plugin = NewReclaimIDPlugin()
+
+// ReclaimIDPlugin is a handler of Reclaim:ID specific records that implements
+// the zonemaster.Plugin interface.
+type ReclaimIDPlugin struct{}
+
+// NewReclaimIDPlugin creates an initialized plugin instance
+func NewReclaimIDPlugin() ReclaimIDPlugin {
+       return ReclaimIDPlugin{}
+}
+
+//----------------------------------------------------------------------
+// Interface implementation
+//----------------------------------------------------------------------
+
+// Name returns the plugin name (sub-system name)
+func (p *ReclaimIDPlugin) Name() string {
+       return "Reclaim:ID"
+}
+
+// CanHandle returns a list of resource record types that are handled by the
+// plugin
+func (p *ReclaimIDPlugin) CanHandle() (list []uint32) {
+       for t := range handledTypes {
+               list = append(list, t)
+       }
+       return
+}
+
+//go:embed gui.htpl
+var tpl []byte
+
+// Template returns the new / edit template for resource record types
+// handled by the plugin.
+func (p *ReclaimIDPlugin) Template() string {
+       return string(tpl)
+}
+
+// TemplateNames returns the names of the new / edit template
+func (p *ReclaimIDPlugin) TemplateNames() (string, string) {
+       return "new_reclaim", "edit_reclaim"
+}
+
+// Value returns a human-readable description of RR data
+func (p *ReclaimIDPlugin) Value(t uint32, rr []byte) string {
+       return "(not handled yet)"
+}
+
+// ToMap converts resource record data into GUI template variables
+func (p *ReclaimIDPlugin) ToMap(t uint32, rr []byte) map[string]string {
+       return make(map[string]string)
+}
+
+// FromMap converts a GUI template variables into resource record data
+func (p *ReclaimIDPlugin) FromMap(t uint32, vars map[string]string) []byte {
+       return make([]byte, 0)
+}
+
+//----------------------------------------------------------------------
+// helper functions
+//----------------------------------------------------------------------

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]