tordam

A library for peer discovery inside the Tor network
git clone https://git.parazyd.org/tordam
Log | Files | Refs | README | LICENSE

commit 9273ef22a622c87441f711236c2d11515da6914f
parent b97811cbf9b58bcf190ed3cc88aa414a04cc84e6
Author: parazyd <parazyd@dyne.org>
Date:   Thu, 19 Jul 2018 16:22:53 +0200

Implement -t flag for choosing between nodes being (in)valid initially.

Diffstat:
Mcmd/dam-dir/main.go | 9+++++++++
Mpkg/damlib/config.go | 4++++
Mpkg/damlib/validate.go | 6+++++-
3 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/cmd/dam-dir/main.go b/cmd/dam-dir/main.go @@ -22,6 +22,7 @@ package main import ( "encoding/json" + "flag" "log" "net/http" "os" @@ -213,6 +214,14 @@ func handleElse(rw http.ResponseWriter, request *http.Request) {} func main() { var wg sync.WaitGroup + var t bool + + flag.BoolVar(&t, "t", false, "Mark all new nodes valid initially") + flag.Parse() + + if t { + lib.Testnet = true + } // Chdir to our working directory. if _, err := os.Stat(lib.Cwd); os.IsNotExist(err) { diff --git a/pkg/damlib/config.go b/pkg/damlib/config.go @@ -46,3 +46,7 @@ const TorPortMap = "80:49371,13010:13010,13011:13011,5000:5000" // DirPort is the port where dam-dir will be listening. const DirPort = 49371 + +// Testnet is flipped with a flag in dam-dir and represents if all new +// nodes are initially marked valid or not. +var Testnet = false diff --git a/pkg/damlib/validate.go b/pkg/damlib/validate.go @@ -155,7 +155,11 @@ func ValidateFirstHandshake(req map[string]string) (bool, string) { if ex != 1 { // We did not have this node in redis. info["pubkey"] = pub info["firstseen"] = time.Now().Unix() - info["valid"] = 1 + if Testnet { + info["valid"] = 1 + } else { + info["valid"] = 0 + } } log.Printf("%s: writing to redis\n", req["address"])