mirror of https://github.com/schollz/croc.git
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"
|
humanize "github.com/dustin/go-humanize"
|
||||||
"github.com/schollz/croc/src/croc"
|
"github.com/schollz/croc/src/croc"
|
||||||
"github.com/schollz/utils"
|
"github.com/schollz/croc/src/utils"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -154,6 +154,9 @@ func receive(c *cli.Context) error {
|
||||||
if c.Args().First() != "" {
|
if c.Args().First() != "" {
|
||||||
codePhrase = c.Args().First()
|
codePhrase = c.Args().First()
|
||||||
}
|
}
|
||||||
|
if codePhrase == "" {
|
||||||
|
codePhrase = utils.GetInput("Enter receive code: ")
|
||||||
|
}
|
||||||
return cr.Receive(codePhrase)
|
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)
|
log.Debugf("got %d: %s", messageType, message)
|
||||||
switch step {
|
switch step {
|
||||||
case 0:
|
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.Stop()
|
||||||
spin.Suffix = " performing PAKE..."
|
spin.Suffix = " performing PAKE..."
|
||||||
spin.Start()
|
spin.Start()
|
||||||
log.Debugf("[%d] first, P sends u to Q", step)
|
|
||||||
c.WriteMessage(websocket.BinaryMessage, P.Bytes())
|
|
||||||
case 1:
|
case 1:
|
||||||
// P recieves H(k),v from Q
|
// P recieves H(k),v from Q
|
||||||
log.Debugf("[%d] P computes k, H(k), sends H(k) to Q", step)
|
log.Debugf("[%d] P computes k, H(k), sends H(k) to Q", step)
|
||||||
|
|
|
@ -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