1
0
mirror of https://github.com/schollz/croc.git synced 2024-11-23 23:54:17 +03:00

fix: shared secret should be read from environmental variable

This commit is contained in:
Zack 2024-05-20 09:46:38 -07:00
parent accb310337
commit e255d472a6

View File

@ -321,6 +321,18 @@ func send(c *cli.Context) (err error) {
// save the config
saveConfig(c, crocOptions)
// if operating system is UNIX, then use environmental variable to set the code
if runtime.GOOS == "linux" {
cr.Options.SharedSecret = os.Getenv("CROC_SECRET")
if cr.Options.SharedSecret == "" {
fmt.Printf(`To use croc you need to set a code phrase using your environmental variables:
export CROC_SECRET="yourcodephrasetouse"
`)
os.Exit(0)
}
}
err = cr.Send(minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders)
return
@ -536,6 +548,18 @@ func receive(c *cli.Context) (err error) {
log.Debugf("wrote %s", configFile)
}
// if operating system is UNIX, then use environmental variable to set the code
if runtime.GOOS == "linux" {
cr.Options.SharedSecret = os.Getenv("CROC_SECRET")
if cr.Options.SharedSecret == "" {
fmt.Printf(`To use croc you need to set a code phrase using your environmental variables:
export CROC_SECRET="yourcodephrasetouse"
`)
os.Exit(0)
}
}
err = cr.Receive()
return
}