mirror of
https://github.com/schollz/croc.git
synced 2025-10-11 05:11:06 +02:00
handle errors from peer
This commit is contained in:
parent
8a843a6a85
commit
93a3ec70e7
2 changed files with 14 additions and 2 deletions
3
main.go
3
main.go
|
@ -2,6 +2,7 @@ package main
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
|
||||
"github.com/schollz/croc/v5/src/croc"
|
||||
)
|
||||
|
@ -43,6 +44,6 @@ func main() {
|
|||
err = c.Receive()
|
||||
}
|
||||
if err != nil {
|
||||
panic(err)
|
||||
fmt.Println(err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -392,6 +392,11 @@ func (c *Client) processMessage(m Message) (err error) {
|
|||
c.log.Debug(c.Pake.SessionKey())
|
||||
c.Step1ChannelSecured = true
|
||||
}
|
||||
case "error":
|
||||
c.spinner.Stop()
|
||||
fmt.Print("\r")
|
||||
err = fmt.Errorf("peer error: %s", m.Message)
|
||||
return err
|
||||
case "fileinfo":
|
||||
var senderInfo SenderInfo
|
||||
var decryptedBytes []byte
|
||||
|
@ -417,7 +422,13 @@ func (c *Client) processMessage(m Message) (err error) {
|
|||
}
|
||||
c.spinner.Stop()
|
||||
fmt.Fprintf(os.Stderr, "\rAccept %s (%s) from machine '%s'? (y/n) ", fname, utils.ByteCountDecimal(totalSize), senderInfo.MachineID)
|
||||
utils.GetInput("")
|
||||
if strings.ToLower(strings.TrimSpace(utils.GetInput(""))) != "y" {
|
||||
err = c.redisdb.Publish(c.nameOutChannel, Message{
|
||||
Type: "error",
|
||||
Message: "refusing files",
|
||||
}.String()).Err()
|
||||
return fmt.Errorf("refused files")
|
||||
}
|
||||
// TODO: accept file question?
|
||||
c.log.Debug(c.FilesToTransfer)
|
||||
c.Step2FileInfoTransfered = true
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue