gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taldir] branch master updated (9fd3f55 -> 29a37cd)


From: gnunet
Subject: [taler-taldir] branch master updated (9fd3f55 -> 29a37cd)
Date: Mon, 11 Jul 2022 19:12:16 +0200

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

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

    from 9fd3f55  s/code/challenge
     new ec53e1e  change default link which is generated to http page
     new 29a37cd  properly generate link. response for rate limit modified. 
still odd

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 cmd/taldir-cli/main.go | 36 ++++++++++++++++++------------------
 pkg/rest/taldir.go     | 13 +------------
 taldir.conf            |  2 +-
 3 files changed, 20 insertions(+), 31 deletions(-)

diff --git a/cmd/taldir-cli/main.go b/cmd/taldir-cli/main.go
index 063e664..f35b6fd 100644
--- a/cmd/taldir-cli/main.go
+++ b/cmd/taldir-cli/main.go
@@ -30,18 +30,18 @@ import (
   "crypto/sha512"
 )
 
-// Generates a link from a code and address
-func generateLink(addr string, code string) string {
+// Generates a link from a challenge and address
+func generateLink(host string, addr string, challenge string) string {
   h := sha512.New()
   h.Write([]byte(addr))
   h_addr := util.EncodeBinaryToString(h.Sum(nil))
-  return "taler://taldir/" + h_addr + "/" + code + "-wallet"
+  return host + "/register/" + h_addr + "/" + challenge
 }
 
 func main() {
-  var solveFlag = flag.Bool("s", false, "Provide a solution for the 
code/pubkey")
+  var solveFlag = flag.Bool("s", false, "Provide a solution for the 
challenge/pubkey")
   var linkFlag = flag.Bool("l", false, "Provide a link for activation")
-  var codeFlag = flag.String("c", "", "Activation code")
+  var challengeFlag = flag.String("c", "", "Activation challenge")
   var pubkeyFlag = flag.String("p", "", "Public key")
   var addressFlag = flag.String("a", "", "Address")
   var delEntryFlag = flag.Bool("d", false, "Delete Entry for the specificied 
address")
@@ -50,28 +50,29 @@ 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(*codeFlag) == 0 || len(*pubkeyFlag) == 0 {
-      fmt.Println("You need to provide an activation code and a public key to 
generate a solution")
+    if len(*challengeFlag) == 0 || len(*pubkeyFlag) == 0 {
+      fmt.Println("You need to provide an activation challenge and a public 
key to generate a solution")
       os.Exit(1)
     }
-    fmt.Println(util.GenerateSolution(*pubkeyFlag, *codeFlag))
+    fmt.Println(util.GenerateSolution(*pubkeyFlag, *challengeFlag))
     os.Exit(0)
   }
   if *linkFlag {
-    if len(*codeFlag) == 0 || len(*addressFlag) == 0 {
-      fmt.Println("You need to provide an activation code and an address to 
generate a link")
+    if len(*challengeFlag) == 0 || len(*addressFlag) == 0 {
+      fmt.Println("You need to provide an activation challenge and an address 
to generate a link")
       os.Exit(1)
     }
-    fmt.Println(generateLink(*addressFlag, *codeFlag))
+    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)
@@ -98,5 +99,4 @@ func main() {
     }
     t.DeleteValidation(*addressFlag)
   }
-
 }
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]