tordam

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

commit 57d5e502e50701fb1352feb2dd2453f5ab74ca7e
parent ece23839a13bb1e2ec29027902076e691f25525b
Author: parazyd <parazyd@dyne.org>
Date:   Mon,  3 Sep 2018 13:53:51 +0200

Add a commandline flag for allowing custom remote directory lists.

The flag reads a comma-separated string and splits it into a slice of
strings to be used with fetchDirlist().

Diffstat:
Mcmd/dam-client/main.go | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go @@ -35,6 +35,7 @@ import ( "os" "os/exec" "strconv" + "strings" "sync" "time" @@ -45,12 +46,6 @@ type msgStruct struct { Secret string } -// Network entry points. These files hold the lists of directories we can -// announce to. Format is "DIR:22mobp7vrb7a4gt2.onion", other lines are ignored. -var dirHosts = []string{ - "https://dam.decodeproject.eu/dirs.txt", -} - func announce(dir string, vals map[string]string, privkey *rsa.PrivateKey) (bool, error) { msg, err := json.Marshal(vals) if err != nil { @@ -207,15 +202,23 @@ func fetchDirlist(locations []string) ([]string, error) { func main() { var d bool var ai int + var dh string + var dirHosts []string flag.BoolVar(&d, "d", false, "Don't fetch remote entry points") flag.IntVar(&ai, "ai", 10, "Announce interval in minutes") + flag.StringVar(&dh, "dh", "https://dam.decodeproject.eu/dirs.txt", + "A remote list of entry points/directories (comma-separated)") flag.Parse() if d { lib.Noremote = true } + // Network entry points. These files hold the lists of directories we can + // announce to. Format is "DIR:22mobp7vrb7a4gt2.onion", other lines are ignored. + dirHosts = strings.Split(dh, ",") + if _, err := os.Stat(lib.Cwd); os.IsNotExist(err) { err := os.Mkdir(lib.Cwd, 0700) lib.CheckError(err)