mirror of
https://github.com/schollz/croc.git
synced 2024-11-27 12:34:19 +03:00
get receive code if empty
This commit is contained in:
parent
e5b3e6e06e
commit
1add7e94c9
5
main.go
5
main.go
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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
15
src/utils/getinput.go
Normal 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)
|
||||
}
|
Loading…
Reference in New Issue
Block a user