tImplement "-d" flag in dam-client to allow not fetching remote directories. - tordam - A library for peer discovery inside the Tor network HTML git clone https://git.parazyd.org/tordam DIR Log DIR Files DIR Refs DIR README DIR LICENSE --- DIR commit c92808cd8466674fedd351839a82317d65e468df DIR parent 7def56bf98aecf7c77ff680a5686f462de7be033 HTML 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: M cmd/dam-client/main.go | 24 ++++++++++++++++++------ M pkg/damlib/config.go | 4 ++++ 2 files changed, 22 insertions(+), 6 deletions(-) --- DIR diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go t@@ -28,6 +28,7 @@ import ( "crypto/rsa" "encoding/base64" "encoding/json" + "flag" "io/ioutil" "log" "math/big" t@@ -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 t@@ -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) DIR diff --git a/pkg/damlib/config.go b/pkg/damlib/config.go t@@ -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