mirror of
https://github.com/schollz/croc.git
synced 2024-11-23 15:44:16 +03:00
add stdin
This commit is contained in:
parent
ebad469554
commit
f315a0bb79
11
main.go
11
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 {
|
||||
|
@ -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
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user