cmd/derper: add default -c arguments

This adds some convenient defaults for -c, so that user-provided DERPs require less command line
flags.

Signed-off-by: julianknodt <julianknodt@gmail.com>
This commit is contained in:
julianknodt 2021-07-14 15:20:38 -07:00 committed by Julian Knodt
parent ee71c966fd
commit 9d4eddcef8

View File

@ -58,7 +58,12 @@ func loadConfig() config {
return config{PrivateKey: mustNewKey()}
}
if *configPath == "" {
log.Fatalf("derper: -c <config path> not specified")
if os.Getuid() == 0 {
*configPath = "/var/lib/derper/derper.key"
} else {
*configPath = "derper.key"
}
log.Printf("no config path specified; using %s", *configPath)
}
b, err := ioutil.ReadFile(*configPath)
switch {