commit b8a467ffa6fc0d25e5de40d2f872ce7e360844be
parent 98efaf065bf2a9f5e08156b268d41b93bff3739a
Author: parazyd <parazyd@dyne.org>
Date: Thu, 7 Dec 2017 23:56:55 +0100
Expand the nodeStruct struct to hold more information
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/go/ddir/ddir.go b/go/ddir/ddir.go
@@ -8,6 +8,7 @@ import (
"log"
"net/http"
"sync"
+ "time"
"../lib"
)
@@ -20,6 +21,10 @@ type nodeStruct struct {
Message string
Signature string
Secret string
+ Pubkey string
+ Firstseen int64
+ Lastseen int64
+ Valid bool
}
func handlePost(rw http.ResponseWriter, request *http.Request) {
@@ -59,6 +64,11 @@ func handlePost(rw http.ResponseWriter, request *http.Request) {
pubkey, err := lib.ParsePubkey(pkey)
lib.CheckError(err)
+ n.Pubkey = string(pkey)
+ now := time.Now()
+ n.Firstseen = now.Unix()
+ n.Lastseen = now.Unix()
+
if len(req["secret"]) != 88 {
// Client did not send a decrypted secret.
randString, err := lib.GenRandomASCII(64)
@@ -97,6 +107,8 @@ func handlePost(rw http.ResponseWriter, request *http.Request) {
ret := map[string]string{
"secret": "Welcome to the DECODE network!",
}
+ n.Valid = false
+
jsonVal, err := json.Marshal(ret)
lib.CheckError(err)