mirror of https://github.com/schollz/croc.git
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
This commit is contained in:
parent
928ee1f496
commit
9968bbf824
|
@ -223,6 +223,8 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
errchan := make(chan error, 1)
|
errchan := make(chan error, 1)
|
||||||
|
|
||||||
if !c.Options.DisableLocal {
|
if !c.Options.DisableLocal {
|
||||||
|
// add two things to the error channel
|
||||||
|
errchan = make(chan error, 2)
|
||||||
// setup the relay locally
|
// setup the relay locally
|
||||||
for _, port := range c.Options.RelayPorts {
|
for _, port := range c.Options.RelayPorts {
|
||||||
|
|
||||||
|
@ -287,6 +289,7 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
err = errors.Wrap(err, fmt.Sprintf("could not connect to %s", c.Options.RelayAddress))
|
err = errors.Wrap(err, fmt.Sprintf("could not connect to %s", c.Options.RelayAddress))
|
||||||
log.Debug(err)
|
log.Debug(err)
|
||||||
|
errchan <- err
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debugf("connection established: %+v", conn)
|
log.Debugf("connection established: %+v", conn)
|
||||||
|
@ -320,7 +323,15 @@ func (c *Client) Send(options TransferOptions) (err error) {
|
||||||
errchan <- c.transfer(options)
|
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
|
// Receive will receive a file
|
||||||
|
|
Loading…
Reference in New Issue