1
1
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 05:11:06 +02:00

fix: address shared secret before creatgin

This commit is contained in:
Zack 2024-05-20 10:16:02 -07:00
parent 863dabb93a
commit bb018fd725

View file

@ -313,18 +313,11 @@ func send(c *cli.Context) (err error) {
return
}
cr, err := croc.New(crocOptions)
if err != nil {
return
}
// 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 == "" {
log.Debug("forcing code phrase from environmental variable")
crocOptions.SharedSecret = os.Getenv("CROC_SECRET")
if crocOptions.SharedSecret == "" {
fmt.Printf(`To use croc you need to set a code phrase using your environmental variables:
export CROC_SECRET="yourcodephrasetouse"
@ -333,6 +326,14 @@ export CROC_SECRET="yourcodephrasetouse"
}
}
cr, err := croc.New(crocOptions)
if err != nil {
return
}
// save the config
saveConfig(c, crocOptions)
err = cr.Send(minimalFileInfos, emptyFoldersToTransfer, totalNumberFolders)
return
@ -525,6 +526,17 @@ func receive(c *cli.Context) (err error) {
return err
}
}
// if operating system is UNIX, then use environmental variable to set the code
if runtime.GOOS == "linux" {
crocOptions.SharedSecret = os.Getenv("CROC_SECRET")
if crocOptions.SharedSecret == "" {
fmt.Printf(`To use croc you need to set a code phrase using your environmental variables:
export CROC_SECRET="yourcodephrasetouse"
`)
os.Exit(0)
}
}
cr, err := croc.New(crocOptions)
if err != nil {
@ -548,18 +560,6 @@ 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
}