diff --git a/main.go b/main.go index d84f505..51a168b 100644 --- a/main.go +++ b/main.go @@ -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 { diff --git a/src/api.go b/src/api.go index 4766ee6..4aefffc 100644 --- a/src/api.go +++ b/src/api.go @@ -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 diff --git a/src/files.go b/src/files.go index 19ceba8..9600907 100644 --- a/src/files.go +++ b/src/files.go @@ -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) {