gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taldir] 02/02: properly generate link. response for rate limit mo


From: gnunet
Subject: [taler-taldir] 02/02: properly generate link. response for rate limit modified. still odd
Date: Mon, 11 Jul 2022 19:12:18 +0200

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

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

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

    properly generate link. response for rate limit modified. still odd
---
 cmd/taldir-cli/main.go | 17 +++++++++--------
 pkg/rest/taldir.go     | 13 +------------
 taldir.conf            |  2 +-
 3 files changed, 11 insertions(+), 21 deletions(-)

diff --git a/cmd/taldir-cli/main.go b/cmd/taldir-cli/main.go
index 54259df..f35b6fd 100644
--- 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
index 3ff1ffd..9040f07 100644
--- 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
index f688081..4b87274 100644
--- 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

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