Merge pull request #886 from micro/tunnel-error

Don't error where the connection is not unicast
This commit is contained in:
Asim Aslam 2019-10-25 15:48:09 +01:00 committed by GitHub
commit e85863d6cc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,7 +110,7 @@ func (s *session) newMessage(typ string) *message {
func (s *session) waitFor(msgType string, timeout time.Duration) (*message, error) { func (s *session) waitFor(msgType string, timeout time.Duration) (*message, error) {
now := time.Now() now := time.Now()
after := func() time.Duration { after := func(timeout time.Duration) time.Duration {
d := time.Since(now) d := time.Since(now)
// dial timeout minus time since // dial timeout minus time since
wait := timeout - d wait := timeout - d
@ -133,7 +133,7 @@ func (s *session) waitFor(msgType string, timeout time.Duration) (*message, erro
} }
// got the message // got the message
return msg, nil return msg, nil
case <-time.After(after()): case <-time.After(after(timeout)):
return nil, ErrDialTimeout return nil, ErrDialTimeout
case <-s.closed: case <-s.closed:
return nil, io.EOF return nil, io.EOF
@ -188,9 +188,6 @@ func (s *session) Discover() error {
// wait for announce // wait for announce
_, err = s.waitFor("announce", dialTimeout) _, err = s.waitFor("announce", dialTimeout)
if err != nil {
return err
}
// if its multicast just go ahead because this is best effort // if its multicast just go ahead because this is best effort
if s.mode != Unicast { if s.mode != Unicast {