From f3e2a260d95a99e3a677d1137318ae4ede8e8bdb Mon Sep 17 00:00:00 2001 From: Zack Scholl Date: Wed, 1 May 2019 10:38:31 -0600 Subject: [PATCH] update relay address if a peer is found --- src/croc/croc.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/croc/croc.go b/src/croc/croc.go index 02da35d5..b25c3f9e 100644 --- a/src/croc/croc.go +++ b/src/croc/croc.go @@ -312,7 +312,8 @@ func (c *Client) Send(options TransferOptions) (err error) { // Receive will receive a file func (c *Client) Receive() (err error) { - // look for peers first + // recipient will look for peers first + // and continue if it doesn't find any within 100 ms if !c.Options.DisableLocal { discoveries, err := peerdiscovery.Discover(peerdiscovery.Settings{ Limit: 1, @@ -320,7 +321,9 @@ func (c *Client) Receive() (err error) { Delay: 10 * time.Millisecond, TimeLimit: 100 * time.Millisecond, }) - _ = err + if err == nil && len(discoveries) > 0 { + c.Options.RelayAddress = fmt.Sprintf("%s:%s", discoveries[0].Address, discoveries[0].Payload) + } log.Debugf("discoveries: %+v", discoveries) log.Debug("establishing connection") }