mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 13:21:00 +02:00
Merge pull request #701 from schollz/issue598
fix: shared secret should be read from environmental variable
This commit is contained in:
commit
863dabb93a
1 changed files with 24 additions and 0 deletions
|
@ -321,6 +321,18 @@ func send(c *cli.Context) (err error) {
|
||||||
// save the config
|
// save the config
|
||||||
saveConfig(c, crocOptions)
|
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)
|
err = cr.Send(minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders)
|
||||||
|
|
||||||
return
|
return
|
||||||
|
@ -536,6 +548,18 @@ func receive(c *cli.Context) (err error) {
|
||||||
log.Debugf("wrote %s", configFile)
|
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()
|
err = cr.Receive()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue