commit 59d1e9e8085040927018749c7f7f85a5a6ecf893
parent 38b8caf87dc12857c27c2e83ce896d660e45cae3
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date: Thu, 18 Sep 2025 11:18:19 +0200
make tests pass again
Diffstat:
4 files changed, 48 insertions(+), 10 deletions(-)
diff --git a/README.md b/README.md
@@ -65,6 +65,43 @@ For the `[taldir-pq]` section:
Examples and defaults for the configuration can be found in the `taldir.conf` file shipped with this software.
+# Disseminators
+
+Aliases will be disseminated through the REST API of the taler-directory service itself by default.
+It is also possible to use other external disseminators.
+At this point in time, only the GNU Name System (RFC 9498) is availiable as an additional
+dissemiantion mechanism.
+
+You can activate it through the configuration:
+
+```
+[taldir-disseminator-gns]
+enabled = true
+zone = "testtaldir"
+expiration = "1d"
+```
+
+If `enabled` is set to `true`, the disseminator is enabled.
+The GNS zone with the name configured under the `zone` key is where records
+will be stored upon dissemination.
+`expiration` is a relative expiration string (`1d` is one day, `15m` would be 15 minutes).
+This defines the TTL of the records in GNS after which a re-resolution by resolvers
+is required.
+The default value of 1 day should be fine in most cases.
+Note that this means that there will be up to 1 day of delay between the deletion or update of an
+alias mapping and its removal/availability through GNS.
+
+The GNS dissemination plugin requires a working GNUnet (https://www.gnunet.org) peer to be installed and started and the respective configured zone to exist.
+
+Aliases will then be available for resolution in GNS using the `$H_ADDRESS` (see https://docs.taler.net/core/api-taldir.html#address-lookup) in GNS as TXT record:
+
+```
+
+ $ gnunet-gns -u $H_ADDRESS.$ZONE
+```
+
+where `$ZONE` is either the zone public key of the configured dissemination zone or a human-readable mapping to it (See the documentation of GNS for details).
+
# Validators
Taldir validators are executable programs which are used to transfer a validation
diff --git a/cmd/taldir-server/main_test.go b/cmd/taldir-server/main_test.go
@@ -20,7 +20,6 @@ package main_test
import (
"bytes"
- "crypto/sha512"
"fmt"
"io"
"log"
@@ -138,17 +137,18 @@ func TestMain(m *testing.M) {
Datahome: "./testdata",
Db: db,
Merchant: merch,
+ Loglevel: taldir.LogDebug,
})
- log.Println("hello")
+ log.Printf("have %d validators", len(t.Validators))
+ log.Print(t.Validators)
code := m.Run()
t.ClearDatabase()
os.Exit(code)
}
func getHAddress(addr string) string {
- h := sha512.New()
- h.Write([]byte(addr))
- return util.Base32CrockfordEncode(h.Sum(nil))
+ ha := t.HashAlias("test", addr)
+ return util.Base32CrockfordEncode(ha)
}
func TestNoEntry(s *testing.T) {
diff --git a/cmd/taldir-server/testdata/taldir-test.conf b/cmd/taldir-server/testdata/taldir-test.conf
@@ -1,6 +1,5 @@
[taldir]
production = false
-validators = "test-cost test"
host = "https://taldir.net"
bind_to = "localhost:11000"
salt = "ChangeMe"
diff --git a/pkg/taldir/taldir.go b/pkg/taldir/taldir.go
@@ -337,7 +337,7 @@ func (t *Taldir) disseminateEntries() error {
// Hashes the alias with its type in a prefix-free fashion
// SHA512(len(atype||alias)||atype||alias)
-func hashAlias(atype string, alias string) []byte {
+func (t *Taldir) HashAlias(atype string, alias string) []byte {
h := sha512.New()
b := make([]byte, 4)
binary.BigEndian.PutUint32(b, uint32(len(atype)+len(alias)))
@@ -496,7 +496,7 @@ func (t *Taldir) registerRequest(w http.ResponseWriter, r *http.Request) {
// Setup validation object. Retrieve object from DB if it already
// exists.
- hAddressBin := hashAlias(validator.Name(), req.Address)
+ hAddressBin := t.HashAlias(validator.Name(), req.Address)
hAddress := util.Base32CrockfordEncode(hAddressBin)
validation.HAddress = hAddress
validation.ValidatorName = validator.Name()
@@ -664,7 +664,7 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r *http.Request) {
}
// FIXME requires a prefix-free encoding
- hAddressBin := hashAlias(validation.ValidatorName, address)
+ hAddressBin := t.HashAlias(validation.ValidatorName, address)
expectedHAddress := util.Base32CrockfordEncode(hAddressBin)
if expectedHAddress != validation.HAddress {
@@ -815,7 +815,7 @@ func (t *Taldir) methodLookupResultPage(w http.ResponseWriter, r *http.Request)
http.Redirect(w, r, fmt.Sprintf("/landing/"+val.Name()+"?error=%s", emsg), http.StatusSeeOther)
return
} else {
- hAddressBin := hashAlias(val.Name(), r.URL.Query().Get("address"))
+ hAddressBin := t.HashAlias(val.Name(), r.URL.Query().Get("address"))
hAddress := util.Base32CrockfordEncode(hAddressBin[:])
hsAddress := saltHAddress(hAddress, t.Salt)
err = t.Db.First(&entry, "hs_address = ?", hsAddress).Error
@@ -963,7 +963,9 @@ func (t *Taldir) Initialize(cfg TaldirConfig) {
t.Logger.Logf(LogInfo, "`%s` validator disabled.\n", vname)
t.Validators[vname] = &v
}
+ t.Logger.Logf(LogDebug, "`%s` validator enabled.\n", vname)
}
+ t.Logger.Logf(LogDebug, "Found %d validators.\n", len(t.Validators))
t.Disseminators = make(map[string]Disseminator)
gnsdisseminator := make_gns_disseminator(&cfg)
if gnsdisseminator.IsEnabled() {