don't reconnect to ourself
When we discover that a connection target address leads to ourself we set the retry time to the zero time.Time value - the only special time.Time value. We use that marker to a) suppress subsequent connection attempts, and b) display the next retry as 'never' in `weave status|report`. Closes #1305.
This commit is contained in:
1 parent
bbc91c1273
commit
d8e8cd6e51
3 files changed
+17
-2
No files matched your search
@@ -2,6 +2,7 @@ package router
|
||||
|
||||
import (
|
||||
"encoding/binary"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net"
|
||||
"strconv"
|
||||
@@ -28,6 +29,8 @@ const (
|
||||
TieBreakTied
|
||||
)
|
||||
|
||||
var ErrConnectToSelf = errors.New("Cannot connect to ourself")
|
||||
|
||||
type RemoteConnection struct {
|
||||
local *Peer
|
||||
remote *Peer
|
||||
@@ -437,7 +440,7 @@ func (conn *LocalConnection) registerRemote(remote *Peer, acceptNewPeer bool) er
|
||||
}
|
||||
|
||||
if conn.remote == conn.local {
|
||||
return fmt.Errorf("Cannot connect to ourself")
|
||||
return ErrConnectToSelf
|
||||
}
|
||||
|
||||
return nil
|
||||
|
||||
Reference in new issue
Block a user