0
0
Fork 0
mirror of https://github.com/schollz/croc.git synced 2025-10-11 13:21:00 +02:00

better ui

This commit is contained in:
Zack Scholl 2018-04-22 23:21:40 -07:00
parent 638ca9ef27
commit 1308694711

View file

@ -181,23 +181,20 @@ func (c *Connection) Run() error {
}) })
if c.IsSender { if c.IsSender {
c.Server = "localhost" c.Server = "localhost"
p.Discover() go p.Discover()
fmt.Println("running relay on local address " + GetLocalIP())
fmt.Println([]byte(c.Code))
} else { } else {
fmt.Print("finding local croc relay...")
discovered, err := p.Discover() discovered, err := p.Discover()
if err != nil { if err != nil {
return err return err
} }
fmt.Println(discovered)
if len(discovered) == 0 { if len(discovered) == 0 {
return errors.New("could not find server") return errors.New("could not find server")
} }
c.Server = discovered[0].Address c.Server = discovered[0].Address
fmt.Println(discovered[0].Payload) fmt.Println(discovered[0].Address)
c.Code = string(discovered[0].Payload) c.Code = string(discovered[0].Payload)
time.Sleep(1 * time.Second)
} }
} }
@ -275,7 +272,7 @@ func (c *Connection) Run() error {
} }
if c.Local { if c.Local {
fmt.Fprintf(os.Stderr, "Receive with: croc --code %s --server %s --yes\n", c.Code, GetLocalIP()) fmt.Fprintf(os.Stderr, "Receive with: croc --local\n")
} else { } else {
fmt.Fprintf(os.Stderr, "Code is: %s\n", c.Code) fmt.Fprintf(os.Stderr, "Code is: %s\n", c.Code)
} }
@ -500,7 +497,7 @@ func (c *Connection) runClient() error {
return nil // connection was in use, just quit cleanly return nil // connection was in use, just quit cleanly
} }
timeSinceStart := time.Since(responses.startTime) / time.Second timeSinceStart := time.Since(responses.startTime).Nanoseconds()
if c.IsSender { if c.IsSender {
if responses.gotTimeout { if responses.gotTimeout {
@ -577,7 +574,7 @@ func (c *Connection) runClient() error {
} }
} }
} }
fmt.Fprintf(os.Stderr, " (%s/s)\n", humanize.Bytes(uint64(float64(c.File.Size)/float64(timeSinceStart)))) fmt.Fprintf(os.Stderr, " (%s/s)\n", humanize.Bytes(uint64(float64(1000000000)*float64(c.File.Size)/float64(timeSinceStart))))
return nil return nil
} }