taldir

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

commit 29a37cd97541ce039eaedd6de851ec0cd1598d7a
parent ec53e1ebbbd680d1f0e99a7fdbf6b3382e3747be
Author: Martin Schanzenbach <schanzen@gnunet.org>
Date:   Mon, 11 Jul 2022 19:12:13 +0200

properly generate link. response for rate limit modified. still odd

Diffstat:
Mcmd/taldir-cli/main.go | 17+++++++++--------
Mpkg/rest/taldir.go | 13+------------
Mtaldir.conf | 2+-
3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/cmd/taldir-cli/main.go b/cmd/taldir-cli/main.go @@ -35,7 +35,7 @@ func generateLink(host string, addr string, challenge string) string { h := sha512.New() h.Write([]byte(addr)) h_addr := util.EncodeBinaryToString(h.Sum(nil)) - return host + "/register/" + h_addr + "/" + code + return host + "/register/" + h_addr + "/" + challenge } func main() { @@ -50,6 +50,13 @@ func main() { var dropFlag = flag.Bool("D", false, "Drop all data in table (DANGEROUS!)") var cfgFlag = flag.String("C", "", "Configuration file to use") flag.Parse() + cfgfile := "taldir.conf" + if len(*cfgFlag) != 0 { + cfgfile = *cfgFlag + } + t := taldir.Taldir{} + t.Initialize(cfgfile) + host := t.Cfg.Section("taldir").Key("host").MustString("http://localhost") if *solveFlag { if len(*challengeFlag) == 0 || len(*pubkeyFlag) == 0 { fmt.Println("You need to provide an activation challenge and a public key to generate a solution") @@ -63,15 +70,9 @@ func main() { fmt.Println("You need to provide an activation challenge and an address to generate a link") os.Exit(1) } - fmt.Println(generateLink(*addressFlag, *challengeFlag)) + fmt.Println(generateLink(host, *addressFlag, *challengeFlag)) os.Exit(0) } - cfgfile := "taldir.conf" - if len(*cfgFlag) != 0 { - cfgfile = *cfgFlag - } - t := taldir.Taldir{} - t.Initialize(cfgfile) if *dropFlag { fmt.Println("Really delete all data in database? [y/N]:") reader := bufio.NewReader(os.Stdin) diff --git a/pkg/rest/taldir.go b/pkg/rest/taldir.go @@ -72,9 +72,6 @@ type Taldir struct { // The address salt Salt string - // Request frequency - RequestFrequency int64 - // Challence TTL ChallengeTtl time.Duration @@ -315,13 +312,6 @@ func (t *Taldir) validationRequest(w http.ResponseWriter, r *http.Request){ if validation.LastSolutionTimeframeStart.Add(t.SolutionTimeframe).After(time.Now()) { if validation.SolutionAttemptCount > t.SolutionAttemptsMax { w.WriteHeader(429) - rlResponse := RateLimitedResponse{ - Code: gana.TALDIR_REGISTER_RATE_LIMITED, - RequestFrequency: t.RequestFrequency, - Hint: "Solution attempt rate limit reached", - } - jsonResp, _ := json.Marshal(rlResponse) - w.Write(jsonResp) return } } else { @@ -426,7 +416,7 @@ func (t *Taldir) registerRequest(w http.ResponseWriter, r *http.Request){ w.WriteHeader(429) rlResponse := RateLimitedResponse{ Code: gana.TALDIR_REGISTER_RATE_LIMITED, - RequestFrequency: t.RequestFrequency, + RequestFrequency: t.ChallengeTtl.Microseconds() / int64(t.ValidationInitiationMax), Hint: "Registration rate limit reached", } jsonResp, _ := json.Marshal(rlResponse) @@ -720,7 +710,6 @@ func (t *Taldir) Initialize(cfgfile string) { if "" == t.Salt { t.Salt = t.Cfg.Section("taldir").Key("salt").MustString("ChangeMe") } - t.RequestFrequency = t.Cfg.Section("taldir").Key("request_frequency_microseconds").MustInt64(1000) t.setupHandlers() } diff --git a/taldir.conf b/taldir.conf @@ -1,7 +1,7 @@ [taldir] production = false validators = "twitter" -host = "https://taldir.net" +host = "https://taldir.gnunet.org" bind_to = "localhost:11000" salt = "ChangeMe" monthly_fee = KUDOS:1