gnunet-svn
[Top][All Lists]
Advanced

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

[taldir] branch master updated: start implementing disseminator function


From: Admin
Subject: [taldir] branch master updated: start implementing disseminator functionality for GNS/DNS
Date: Sat, 07 Jun 2025 22:46:09 +0200

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

martin-schanzenbach pushed a commit to branch master
in repository taldir.

The following commit(s) were added to refs/heads/master by this push:
     new 5f0b943  start implementing disseminator functionality for GNS/DNS
5f0b943 is described below

commit 5f0b943e9a12cbbac0f435f224ffb80c69c967b0
Author: Martin Schanzenbach <schanzen@gnunet.org>
AuthorDate: Sat Jun 7 22:45:58 2025 +0200

    start implementing disseminator functionality for GNS/DNS
---
 pkg/rest/taldir.go | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 56 insertions(+)

diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go
index 6c1a39e..a9b82db 100644
--- a/pkg/rest/taldir.go
+++ b/pkg/rest/taldir.go
@@ -88,6 +88,9 @@ type Taldir struct {
        // Map of supported validators as defined in the configuration
        Validators map[string]Validator
 
+       // Map of supported disseminators as defined in the configuration
+       Disseminators map[string]Disseminator
+
        // imprint page
        ImprintTpl *template.Template
 
@@ -177,6 +180,16 @@ type Validator struct {
        LandingPageTpl *template.Template
 }
 
+type Disseminator struct {
+
+       // Disseminator name
+       Name string
+
+       // The command to call for dissemination
+       Command string
+
+}
+
 // VersionResponse is the JSON response of the /config endpoint
 type VersionResponse struct {
        // libtool-style representation of the Merchant protocol version, see
@@ -378,6 +391,37 @@ func (t *Taldir) getSingleEntry(w http.ResponseWriter, r 
*http.Request) {
        w.WriteHeader(http.StatusNotFound)
 }
 
+// Disseminate entry
+func (t *Taldir) disseminateEntry(e Entry) error {
+       for _, d := range t.Disseminators {
+               path, err := exec.LookPath(d.Command)
+               if err != nil {
+                       t.Logf(LogError, err.Error()+"\n")
+                       return fmt.Errorf("path of command not found: %w", err)
+               }
+               t.Logf(LogDebug, "Found `%s' in path as `%s'\n", d.Command, 
path)
+               out, err := exec.Command(path, e.HsAddress, 
e.TargetUri).Output()
+               t.Logf(LogDebug, "Executing `%s %s %s `\n", path, e.HsAddress, 
e.TargetUri)
+               if err != nil {
+                       return fmt.Errorf("failed to execute disseminator 
command: `%s', %w", out, err)
+               }
+       }
+       return nil
+}
+
+// Disseminate all entries
+func (t *Taldir) disseminateEntries() error {
+       var entries []Entry
+       t.Db.Where("1 = 1").Find(&entries)
+       for _, e := range entries {
+               err := t.disseminateEntry(e)
+               if err != nil {
+                       return fmt.Errorf("failed to disseminate `%s': %w", 
e.HsAddress, err)
+               }
+       }
+       return nil
+}
+
 // Hashes an identity key (e.g. sha256(<email address>)) with a salt for
 // Lookup and storage.
 func saltHAddress(hAddress string, salt string) string {
@@ -452,6 +496,7 @@ func (t *Taldir) validationRequest(w http.ResponseWriter, r 
*http.Request) {
                        }
                } else {
                        t.Db.Save(&entry)
+                       t.disseminateEntry(entry)
                }
        } else {
                if validation.TargetUri == "" {
@@ -1020,6 +1065,17 @@ func (t *Taldir) Initialize(cfg TaldirConfig) {
                        ValidAliasRegex: 
sec.Key("valid_alias_regex").MustString(""),
                }
        }
+       t.Disseminators = make(map[string]Disseminator)
+       for _, sec := range cfg.Ini.Sections() {
+               if !strings.HasPrefix(sec.Name(), "taldir-disseminator-") {
+                       continue
+               }
+               dname := strings.TrimPrefix(sec.Name(), "taldir-disseminator-")
+               t.Disseminators[dname] = Disseminator{
+                       Name:            dname,
+                       Command:         sec.Key("command").MustString(""),
+               }
+       }
        t.ChallengeBytes = 
cfg.Ini.Section("taldir").Key("challenge_bytes").MustInt(16)
        t.ValidationInitiationMax = 
cfg.Ini.Section("taldir").Key("validation_initiation_max").MustInt64(3)
        t.SolutionAttemptsMax = 
cfg.Ini.Section("taldir").Key("solution_attempt_max").MustInt(3)

-- 
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]