taldir

Directory service to resolve wallet mailboxes by messenger addresses
Log | Files | Refs | Submodules | README | LICENSE

commit 4ac332f78aa21534fb752d8c3cfd269a31bbee2c
parent 7441f2098b2a38d09360796eb0c0d9b14a2735ac
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Tue, 12 Jul 2022 15:36:25 +0200

fix

Diffstat:
Mpkg/rest/taldir.go | 32++++++++++++++++----------------
1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go @@ -166,7 +166,7 @@ type Order struct { // Entry is a mapping from the identity key hash to a wallet key // The identity key hash is sha512(sha512(address)|salt) where identity is // one of the identity key types supported (e.g. an email address) -type Entry struct { +type entry struct { // ORM gorm.Model `json:"-"` @@ -188,7 +188,7 @@ type Entry struct { // The validation stores the identity key (sha256(identity)) the secret // validation reference. The validation reference is sent to the identity // depending on the out-of-band chennel defined through the identity key type. -type Validation struct { +type validation struct { // ORM gorm.Model `json:"-"` @@ -295,7 +295,7 @@ const monthDuration = time.Duration(monthDurationUs * 1000) // identity, e.g. SHA512(<email address>) func (t *Taldir) getSingleEntry(w http.ResponseWriter, r *http.Request){ vars := mux.Vars(r) - var entry Entry + var entry entry hsAddress := saltHAddress(vars["h_address"], t.Salt) var err = t.Db.First(&entry, "hs_address = ?", hsAddress).Error if err == nil { @@ -320,8 +320,8 @@ func saltHAddress(hAddress string, salt string) string { // provided "out of band" using a validation method such as email or SMS func (t *Taldir) validationRequest(w http.ResponseWriter, r *http.Request){ vars := mux.Vars(r) - var entry Entry - var validation Validation + var entry entry + var validation validation var confirm ValidationConfirmation var errDetail ErrorDetail if r.Body == nil { @@ -385,7 +385,7 @@ func (t *Taldir) validationRequest(w http.ResponseWriter, r *http.Request){ } func (t *Taldir) isRateLimited(hAddress string) (bool, error) { - var validationMetadata ValidationMetadata + var validationMetadata validationMetadata err := t.Db.First(&validationMetadata, "h_address = ?", hAddress).Error // NOTE: Check rate limit if err == nil { @@ -417,8 +417,8 @@ func (t *Taldir) registerRequest(w http.ResponseWriter, r *http.Request){ vars := mux.Vars(r) var req RegisterMessage var errDetail ErrorDetail - var validation Validation - var entry Entry + var validation validation + var entry entry var order Order if r.Body == nil { http.Error(w, "No request body", 400) @@ -605,7 +605,7 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r *http.Request) { vars := mux.Vars(r) var walletLink string var png []byte - var validation Validation + var validation validation err := t.Db.First(&validation, "h_address = ?", vars["h_address"]).Error w.Header().Set("Content-Type", "text/html; charset=utf-8") @@ -633,9 +633,9 @@ func (t *Taldir) validationPage(w http.ResponseWriter, r *http.Request) { // ClearDatabase nukes the database (for tests) func (t *Taldir) ClearDatabase() { - t.Db.Where("1 = 1").Delete(&Entry{}) - t.Db.Where("1 = 1").Delete(&Validation{}) - t.Db.Where("1 = 1").Delete(&ValidationMetadata{}) + t.Db.Where("1 = 1").Delete(&entry{}) + t.Db.Where("1 = 1").Delete(&validation{}) + t.Db.Where("1 = 1").Delete(&validationMetadata{}) } func (t *Taldir) termsResponse(w http.ResponseWriter, r *http.Request) { @@ -794,13 +794,13 @@ func (t *Taldir) Initialize(cfgfile string) { panic(err) } t.Db = _db - if err := t.Db.AutoMigrate(&Entry{}); err != nil { + if err := t.Db.AutoMigrate(&entry{}); err != nil { panic(err) } - if err := t.Db.AutoMigrate(&Validation{}); err != nil { + if err := t.Db.AutoMigrate(&validation{}); err != nil { panic(err) } - if err := t.Db.AutoMigrate(&ValidationMetadata{}); err != nil { + if err := t.Db.AutoMigrate(&validationMetadata{}); err != nil { panic(err) } @@ -813,7 +813,7 @@ func (t *Taldir) Initialize(cfgfile string) { } go func() { for true { - tx := t.Db.Where("created_at < ?", time.Now().Add(-validationExp)).Delete(&Validation{}) + tx := t.Db.Where("created_at < ?", time.Now().Add(-validationExp)).Delete(&validation{}) log.Printf("Cleaned up %d stale validations.\n", tx.RowsAffected) time.Sleep(validationExp) }