get receive code if empty

This commit is contained in:
Zack Scholl 2018-09-22 06:10:41 -07:00
parent e5b3e6e06e
commit 1add7e94c9
3 changed files with 23 additions and 3 deletions

View File

@ -9,7 +9,7 @@ import (
humanize "github.com/dustin/go-humanize"
"github.com/schollz/croc/src/croc"
"github.com/schollz/utils"
"github.com/schollz/croc/src/utils"
"github.com/urfave/cli"
)
@ -154,6 +154,9 @@ func receive(c *cli.Context) error {
if c.Args().First() != "" {
codePhrase = c.Args().First()
}
if codePhrase == "" {
codePhrase = utils.GetInput("Enter receive code: ")
}
return cr.Receive(codePhrase)
}

View File

@ -110,11 +110,13 @@ func send(c *websocket.Conn, fname string, codephrase string) (err error) {
log.Debugf("got %d: %s", messageType, message)
switch step {
case 0:
// send pake data
log.Debugf("[%d] first, P sends u to Q", step)
c.WriteMessage(websocket.BinaryMessage, P.Bytes())
// start PAKE spinnner
spin.Stop()
spin.Suffix = " performing PAKE..."
spin.Start()
log.Debugf("[%d] first, P sends u to Q", step)
c.WriteMessage(websocket.BinaryMessage, P.Bytes())
case 1:
// P recieves H(k),v from Q
log.Debugf("[%d] P computes k, H(k), sends H(k) to Q", step)

15
src/utils/getinput.go Normal file
View File

@ -0,0 +1,15 @@
package utils
import (
"bufio"
"fmt"
"os"
"strings"
)
func GetInput(prompt string) string {
reader := bufio.NewReader(os.Stdin)
fmt.Fprintf(os.Stderr, "%s", prompt)
text, _ := reader.ReadString('\n')
return strings.TrimSpace(text)
}