tordam

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

commit c92808cd8466674fedd351839a82317d65e468df
parent 7def56bf98aecf7c77ff680a5686f462de7be033
Author: parazyd <parazyd@dyne.org>
Date:   Thu, 19 Jul 2018 16:50:35 +0200

Implement "-d" flag in dam-client to allow not fetching remote directories.

Diffstat:
Mcmd/dam-client/main.go | 24++++++++++++++++++------
Mpkg/damlib/config.go | 4++++
2 files changed, 22 insertions(+), 6 deletions(-)

diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go @@ -28,6 +28,7 @@ import ( "crypto/rsa" "encoding/base64" "encoding/json" + "flag" "io/ioutil" "log" "math/big" @@ -155,13 +156,15 @@ func fetchDirlist(locations []string) ([]string, error) { log.Println("Grabbing a list of directories.") // Remote network entry points - for _, i := range locations { - log.Println("Fetching", i) - dirs, err := lib.HTTPDownload(i) - if err != nil { - return nil, err + if !(lib.Noremote) { + for _, i := range locations { + log.Println("Fetching", i) + dirs, err := lib.HTTPDownload(i) + if err != nil { + return nil, err + } + dirSlice = lib.ParseDirs(dirSlice, dirs) } - dirSlice = lib.ParseDirs(dirSlice, dirs) } // Local ~/.dam/directories.txt @@ -202,6 +205,15 @@ func fetchDirlist(locations []string) ([]string, error) { } func main() { + var d bool + + flag.BoolVar(&d, "d", false, "Don't fetch remote entry points") + flag.Parse() + + if d { + lib.Noremote = true + } + if _, err := os.Stat(lib.Cwd); os.IsNotExist(err) { err := os.Mkdir(lib.Cwd, 0700) lib.CheckError(err) diff --git a/pkg/damlib/config.go b/pkg/damlib/config.go @@ -50,3 +50,7 @@ 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 + +// Noremote is flipped with a flag in dam-client and disables fetching +// remote entry points (directories) if enabled. +var Noremote = false