0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 21:30:16 +02:00
This commit is contained in:
Zack Scholl 2018-06-30 11:47:07 -07:00
parent 2b61224707
commit 1cdbdcb08e

View file

@ -91,26 +91,18 @@ func (c *Croc) Send(fname string, codePhrase string) (err error) {
func (c *Croc) Receive(codePhrase string) (err error) { func (c *Croc) Receive(codePhrase string) (err error) {
// prepare codephrase // prepare codephrase
c.cs.Lock() c.cs.Lock()
c.cs.channel.codePhrase = codePhrase if len(codePhrase) == 0 {
if len(codePhrase) > 0 {
if len(codePhrase) < 4 {
err = errors.New("code phrase must be more than 4 characters")
c.cs.Unlock()
return
}
c.cs.channel.Channel = codePhrase[:3]
c.cs.channel.passPhrase = codePhrase[3:]
} else {
// prompt codephrase // prompt codephrase
codePhrase = promptCodePhrase() codePhrase = promptCodePhrase()
if len(codePhrase) < 4 {
err = errors.New("code phrase must be more than 4 characters")
c.cs.Unlock()
return
}
c.cs.channel.Channel = codePhrase[:3]
c.cs.channel.passPhrase = codePhrase[3:]
} }
if len(codePhrase) < 4 {
err = errors.New("code phrase must be more than 4 characters")
c.cs.Unlock()
return
}
c.cs.channel.codePhrase = codePhrase
c.cs.channel.Channel = codePhrase[:3]
c.cs.channel.passPhrase = codePhrase[3:]
log.Debugf("codephrase: '%s'", codePhrase) log.Debugf("codephrase: '%s'", codePhrase)
log.Debugf("channel: '%s'", c.cs.channel.Channel) log.Debugf("channel: '%s'", c.cs.channel.Channel)
log.Debugf("passPhrase: '%s'", c.cs.channel.passPhrase) log.Debugf("passPhrase: '%s'", c.cs.channel.passPhrase)