Add an 'outbound' field on each connection,
and only attempt new connections to the remote side of outbound connections.
This commit is contained in:
1 parent
6f89ead9bd
commit
89fce7f98a
8 files changed
+26
-14
No files matched your search
@@ -16,6 +16,7 @@ type Connection interface {
|
||||
BreakTie(Connection) ConnectionTieBreak
|
||||
RemoteTCPAddr() string
|
||||
Established() bool
|
||||
Outbound() bool
|
||||
Shutdown(error)
|
||||
Log(args ...interface{})
|
||||
}
|
||||
@@ -33,6 +34,7 @@ type RemoteConnection struct {
|
||||
remote *Peer
|
||||
remoteTCPAddr string
|
||||
established bool
|
||||
outbound bool
|
||||
}
|
||||
|
||||
type LocalConnection struct {
|
||||
@@ -66,12 +68,13 @@ type ConnectionInteraction struct {
|
||||
payload interface{}
|
||||
}
|
||||
|
||||
func NewRemoteConnection(from, to *Peer, tcpAddr string, established bool) *RemoteConnection {
|
||||
func NewRemoteConnection(from, to *Peer, tcpAddr string, established bool, outbound bool) *RemoteConnection {
|
||||
return &RemoteConnection{
|
||||
local: from,
|
||||
remote: to,
|
||||
remoteTCPAddr: tcpAddr,
|
||||
established: established}
|
||||
established: established,
|
||||
outbound: outbound}
|
||||
}
|
||||
|
||||
func (conn *RemoteConnection) Local() *Peer {
|
||||
@@ -94,6 +97,10 @@ func (conn *RemoteConnection) Established() bool {
|
||||
return conn.established
|
||||
}
|
||||
|
||||
func (conn *RemoteConnection) Outbound() bool {
|
||||
return conn.outbound
|
||||
}
|
||||
|
||||
func (conn *RemoteConnection) Shutdown(error) {
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user