add stdin

This commit is contained in:
Zack Scholl 2018-07-01 14:53:35 -07:00
parent ebad469554
commit f315a0bb79
3 changed files with 11 additions and 3 deletions

11
main.go
View File

@ -103,12 +103,19 @@ func main() {
}
func send(c *cli.Context) error {
if c.Args().First() == "" {
stat, _ := os.Stdin.Stat()
var fname string
if (stat.Mode() & os.ModeCharDevice) == 0 {
fname = "stdin"
} else {
fname = c.Args().First()
}
if fname == "" {
return errors.New("must specify file: croc send [filename]")
}
cr.UseCompression = c.BoolT("compress")
cr.UseEncryption = c.BoolT("encrypt")
return cr.Send(c.Args().First(), c.GlobalString("code"))
return cr.Send(fname, c.GlobalString("code"))
}
func receive(c *cli.Context) error {

View File

@ -84,6 +84,7 @@ func (c *Croc) Send(fname string, codePhrase string) (err error) {
d.TcpPorts = []string{"27140", "27141"}
go d.startRelay()
go d.startServer()
time.Sleep(100 * time.Millisecond)
ce := Init()
ce.WebsocketAddress = "ws://127.0.0.1:8140"
// copy over the information

View File

@ -41,7 +41,7 @@ func (c *Croc) processFile(src string) (err error) {
return
}
// fd.Name is what the user will see
fd.Name = "stdin"
fd.Name = filename
fd.DeleteAfterSending = true
} else {
if !exists(src) {