This commit is contained in:
Zack Scholl 2018-07-01 14:38:25 -07:00
parent b09955561f
commit 0539e425d2
1 changed files with 17 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"net" "net"
"net/url" "net/url"
"os" "os"
@ -101,6 +102,7 @@ func (c *Croc) client(role int, channel string) (err error) {
case <-interrupt: case <-interrupt:
// send Close signal to relay on interrupt // send Close signal to relay on interrupt
log.Debugf("interrupt") log.Debugf("interrupt")
c.cs.RWMutex.
c.cs.Lock() c.cs.Lock()
channel := c.cs.channel.Channel channel := c.cs.channel.Channel
uuid := c.cs.channel.UUID uuid := c.cs.channel.UUID
@ -134,7 +136,20 @@ func (c *Croc) client(role int, channel string) (err error) {
if c.cs.channel.Role == 0 { if c.cs.channel.Role == 0 {
fmt.Fprintf(os.Stderr, "\nTransfer complete.\n") fmt.Fprintf(os.Stderr, "\nTransfer complete.\n")
} else { } else {
fmt.Fprintf(os.Stderr, "\nReceived file written to %s", c.cs.channel.fileMetaData.Name) folderOrFile := "file"
if c.cs.channel.fileMetaData.IsDir {
folderOrFile = "folder"
}
fmt.Fprintf(os.Stderr, "\nReceived %s written to %s", folderOrFile, c.cs.channel.fileMetaData.Name)
// push to stdout if required
if c.Stdout && !c.cs.channel.fileMetaData.IsDir {
var bFile []byte
bFile, err = ioutil.ReadFile(c.cs.channel.fileMetaData.Name)
if err != nil {
return
}
fmt.Print(bFile)
}
} }
} else { } else {
if c.cs.channel.Error != "" { if c.cs.channel.Error != "" {