From 9968bbf82439ec8151735bde0bda2136224fb72b Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 17 Jul 2019 13:04:03 -0600 Subject: [PATCH] addressing issue #141 the local relay is not being used and then the connection is refused but it still hangs in that case is that the sender should give up, prompting the user to try again --- src/croc/croc.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index ae4c6fc..fdbc326 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -223,6 +223,8 @@ func (c *Client) Send(options TransferOptions) (err error) { errchan := make(chan error, 1) if !c.Options.DisableLocal { + // add two things to the error channel + errchan = make(chan error, 2) // setup the relay locally for _, port := range c.Options.RelayPorts { @@ -287,6 +289,7 @@ func (c *Client) Send(options TransferOptions) (err error) { if err != nil { err = errors.Wrap(err, fmt.Sprintf("could not connect to %s", c.Options.RelayAddress)) log.Debug(err) + errchan <- err return } log.Debugf("connection established: %+v", conn) @@ -320,7 +323,15 @@ func (c *Client) Send(options TransferOptions) (err error) { errchan <- c.transfer(options) }() - return <-errchan + err = <-errchan + if err == nil { + // return if no error + return + } + if !c.Options.DisableLocal { + err = <-errchan + } + return err } // Receive will receive a file