tordam

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

commit 402675f627ff126707f5dacd88e85258987941b8
parent 57d5e502e50701fb1352feb2dd2453f5ab74ca7e
Author: parazyd <parazyd@dyne.org>
Date:   Mon,  3 Sep 2018 13:58:56 +0200

Implement flag for (re)generating keypairs.

Using this flag will make dam-client exit cleanly after generating a
keypair.

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

diff --git a/cmd/dam-client/main.go b/cmd/dam-client/main.go @@ -200,12 +200,13 @@ func fetchDirlist(locations []string) ([]string, error) { } func main() { - var d bool + var d, gen bool var ai int var dh string var dirHosts []string flag.BoolVar(&d, "d", false, "Don't fetch remote entry points") + flag.BoolVar(&gen, "gen", false, "Only (re)generate keypairs and exit cleanly") 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)") @@ -226,7 +227,8 @@ func main() { err := os.Chdir(lib.Cwd) lib.CheckError(err) - if _, err := os.Stat(lib.PrivKeyPath); os.IsNotExist(err) { + if _, err := os.Stat(lib.PrivKeyPath); os.IsNotExist(err) || gen { + os.Chmod(lib.PrivKeyPath, 0600) key, err := lib.GenRsa(lib.RsaBits) lib.CheckError(err) err = lib.SavePrivRsa(lib.PrivKeyPath, key) @@ -236,6 +238,9 @@ func main() { err = ioutil.WriteFile("hostname", onionaddr, 0644) lib.CheckError(err) log.Println("Our hostname is:", string(onionaddr)) + if gen { + os.Exit(0) + } } // Start up the hidden service