diff --git a/config/config.go b/config/config.go index 1b605faa..3fc55049 100644 --- a/config/config.go +++ b/config/config.go @@ -91,6 +91,7 @@ type Config struct { Whitelist []string `long:"whitelist" description:"Add an IP network or IP,PeerID that will not be banned or ignore dual channel mode detection. (eg. 192.168.1.0/24 or ::1 or [peer id])"` Blacklist []string `long:"blacklist" description:"Add some IP network or IP that will be banned. (eg. 192.168.1.0/24 or ::1)"` MaxBadResp int `long:"maxbadresp" description:"maxbadresp is the maximum number of bad responses from a peer before we stop talking to it."` + Circuit bool `long:"circuit" description:"All peers will ignore dual channel mode detection"` } func (c *Config) GetMinningAddrs() []types.Address { diff --git a/p2p/common/config.go b/p2p/common/config.go index ee25f8b3..9b032837 100644 --- a/p2p/common/config.go +++ b/p2p/common/config.go @@ -47,4 +47,5 @@ type Config struct { Banning bool // Open or not ban module DisableListen bool LANPeers []string + IsCircuit bool } diff --git a/p2p/service.go b/p2p/service.go index 7151cd37..9f39dbae 100644 --- a/p2p/service.go +++ b/p2p/service.go @@ -626,6 +626,7 @@ func NewService(cfg *config.Config, events *event.Feed, param *params.Params) (* Banning: cfg.Banning, DisableListen: cfg.DisableListen, LANPeers: lanPeers, + IsCircuit: cfg.Circuit, }, ctx: ctx, cancel: cancel, diff --git a/p2p/synch/handshake.go b/p2p/synch/handshake.go index 6194102b..cd742e4c 100644 --- a/p2p/synch/handshake.go +++ b/p2p/synch/handshake.go @@ -203,16 +203,18 @@ func (s *Sync) bidirectionalChannelCapacity(pe *peers.Peer, conn network.Conn) b pe.SetBidChanCap(time.Now()) return true } + if s.p2p.Config().IsCircuit || s.IsWhitePeer(pe.GetID()) { + pe.SetBidChanCap(time.Now()) + return true + } + bidChanLife := pe.GetBidChanCap() if !bidChanLife.IsZero() { if time.Since(bidChanLife) < timeForBidirChanLife { return true } } - if s.IsWhitePeer(pe.GetID()) { - pe.SetBidChanCap(time.Time{}) - return true - } + // peAddr := conn.RemoteMultiaddr() ipAddr := ""