gnunet-svn
[Top][All Lists]
Advanced

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

[taler-taldir] branch master updated (2dc276e -> a23141b)


From: gnunet
Subject: [taler-taldir] branch master updated (2dc276e -> a23141b)
Date: Tue, 19 Apr 2022 15:26:37 +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 2dc276e  Add comments and minor fixes
     new 3227d99  Add readme
     new a23141b  Add salt from configuration; fix bug where config is not used

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:
 README.md   | 36 ++++++++++++++++++++++++++++++++++++
 config.json |  4 +++-
 taldir.go   | 24 ++++++++++++++----------
 3 files changed, 53 insertions(+), 11 deletions(-)
 create mode 100644 README.md

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..8874911
--- /dev/null
+++ b/README.md
@@ -0,0 +1,36 @@
+# External Dependencies
+
+  - "github.com/gorilla/mux"
+  - "gorm.io/gorm"
+  - "gorm.io/driver/sqlite"
+  - "golang.org/x/crypto/argon2"
+
+# Build and Run
+
+Run for testing:
+
+```
+$ go run .
+```
+
+Compile and run:
+
+```
+$ go build
+$ ./taldir
+```
+# Configuration
+
+The configuration file of taldir is ```config.json```.
+The following configuration varaibles exist:
+
+
+  * "production" (boolean): true for a production deployment. Causes verbose 
log messages to be inhibited.
+  * "db_backend" (string): "sqlite" for the SQLite database backend to be used.
+  * "validators" (array): An array of strings for the validators/identity 
types that can be used. Currently supported values: "email"
+  * "email_sender" (string): For email validations, what should the sender 
address be.
+  * "host" (string): For the validation link, which hostname should be used 
(useful if behind proxy).
+  * "bind_to" (string): Where to bind and listen (HTTP server).
+  * "salt" (string): The salt to use for identity key hashes in the databse.
+
+Examples and defaults for the configuration can be found in the 
```config.json``` file shipped with this software. 
diff --git a/config.json b/config.json
index 3c1f173..9e0d381 100644
--- a/config.json
+++ b/config.json
@@ -3,5 +3,7 @@
   "db_backend": "sqlite",
   "validators": ["email","phone"],
   "email_sender": "taldir@taler.net",
-  "host": "https://taldir.net/";
+  "host": "https://taldir.net/";,
+  "bind_to": "localhost:10000",
+  "salt": "ChangeMe" 
 }
diff --git a/taldir.go b/taldir.go
index 8e2520f..b4c4eaf 100644
--- a/taldir.go
+++ b/taldir.go
@@ -23,6 +23,7 @@ type Configuration struct {
   EmailSender string `json:"email_sender"`
   Salt string `json:"salt"`
   Host string `json:"host"`
+  BindTo string `json:"bind_to"`
 }
 
 // A mappind entry from the identity key hash to a wallet key
@@ -96,8 +97,9 @@ func returnSingleEntry(w http.ResponseWriter, r 
*http.Request){
 // Hashes an identity key (e.g. sha256(<email address>)) with a salt for
 // Lookup and storage.
 func hashIdentityKey(idkey string) string {
-    salt := make([]byte, len(config.Salt))
-    return base32.StdEncoding.EncodeToString(argon2.IDKey([]byte(idkey), salt, 
1, 64*1024, 4, 32))
+  fmt.Println("Using salt " + config.Salt)
+  salt := make([]byte, len(config.Salt))
+  return base32.StdEncoding.EncodeToString(argon2.IDKey([]byte(idkey), salt, 
1, 64*1024, 4, 32))
 }
 
 // Called by the registrant to validate the registration request. The 
reference ID was
@@ -136,12 +138,12 @@ func validateSingleEntry(w http.ResponseWriter, r 
*http.Request){
 
 // Generates random reference token used in the validation flow.
 func generateToken() string {
-    randBytes := make([]byte, 32)
-    _, err := rand.Read(randBytes)
-    if err != nil {
-        panic(err)
-    }
-    return base32.StdEncoding.EncodeToString(randBytes)
+  randBytes := make([]byte, 32)
+  _, err := rand.Read(randBytes)
+  if err != nil {
+    panic(err)
+  }
+  return base32.StdEncoding.EncodeToString(randBytes)
 }
 
 // Initiate a registration request for an identity
@@ -196,14 +198,15 @@ func handleRequests() {
   myRouter.HandleFunc("/directory/{identity_key}", 
returnSingleEntry).Methods("GET")
   myRouter.HandleFunc("/validation/{reference}", 
validateSingleEntry).Methods("GET")
   myRouter.HandleFunc("/register/{identity}", 
addPendingValidation).Methods("POST")
-  log.Fatal(http.ListenAndServe(":10000", myRouter))
+  fmt.Println("Listening on " + config.BindTo)
+  log.Fatal(http.ListenAndServe(config.BindTo, myRouter))
 }
 
 func main() {
   file, _ := os.Open("config.json")
   defer file.Close()
   decoder := json.NewDecoder(file)
-  config := Configuration{}
+  config = Configuration{}
   err := decoder.Decode(&config)
   if err != nil {
     fmt.Println("error:", err)
@@ -212,6 +215,7 @@ func main() {
     fmt.Println("Production mode enabled") 
   }
   validators = make(map[string]bool)
+  fmt.Println(config.BindTo)
   fmt.Println("Enabled validators:", config.Validators)
   for _, a := range config.Validators {
     validators[a] = true

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