mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 21:30:16 +02:00
fix bug
This commit is contained in:
parent
2b61224707
commit
1cdbdcb08e
1 changed files with 9 additions and 17 deletions
26
src/api.go
26
src/api.go
|
@ -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)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue