From d454b1b25f99518e5123df6de3a17c0797cb494f Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Wed, 30 May 2018 21:44:39 -0400 Subject: [PATCH] SkipDuplicate -> AllowDuplicate; fix p2p test on mac --- CHANGELOG.md | 4 ++++ config/config.go | 5 +++-- p2p/pex/pex_reactor_test.go | 2 +- p2p/switch.go | 2 +- p2p/switch_test.go | 5 +++-- 5 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f19c543d1..dd5cad4aa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,12 +10,16 @@ BREAKING: FEATURES - [rpc] the RPC documentation is now published to https://tendermint.github.io/slate +- [p2p] AllowDuplicateIP config option to refuse connections from same IP. + - true by default for now, false by default in next breaking release +- [docs] Add docs for query, tx indexing, events, pubsub IMPROVEMENTS: - [consensus] consensus reactor now receives events from a separate event bus, which is not dependant on external RPC load - [consensus/wal] do not look for height in older files if we've seen height - 1 +- [docs] Various cleanup and link fixes ## 0.19.6 diff --git a/config/config.go b/config/config.go index 932e1ae8e..aabc3d05a 100644 --- a/config/config.go +++ b/config/config.go @@ -294,7 +294,7 @@ type P2PConfig struct { PrivatePeerIDs string `mapstructure:"private_peer_ids"` // Toggle to disable guard against peers connecting from the same ip. - SkipDuplicatePeerIPCheck bool `mapstructure:"skip_duplicate_peer_ip_check"` + AllowDuplicateIP bool `mapstructure:"allow_duplicate_ip"` } // DefaultP2PConfig returns a default configuration for the peer-to-peer layer @@ -311,6 +311,7 @@ func DefaultP2PConfig() *P2PConfig { PexReactor: true, SeedMode: false, AuthEnc: true, + AllowDuplicateIP: true, // so non-breaking yet } } @@ -320,7 +321,7 @@ func TestP2PConfig() *P2PConfig { cfg.ListenAddress = "tcp://0.0.0.0:36656" cfg.SkipUPNP = true cfg.FlushThrottleTimeout = 10 - cfg.SkipDuplicatePeerIPCheck = true + cfg.AllowDuplicateIP = true return cfg } diff --git a/p2p/pex/pex_reactor_test.go b/p2p/pex/pex_reactor_test.go index 06fe6174e..307427b5a 100644 --- a/p2p/pex/pex_reactor_test.go +++ b/p2p/pex/pex_reactor_test.go @@ -27,7 +27,7 @@ var ( func init() { config = cfg.DefaultP2PConfig() config.PexReactor = true - config.SkipDuplicatePeerIPCheck = true + config.AllowDuplicateIP = true } func TestPEXReactorBasic(t *testing.T) { diff --git a/p2p/switch.go b/p2p/switch.go index 7656b9b02..69a7badbd 100644 --- a/p2p/switch.go +++ b/p2p/switch.go @@ -577,7 +577,7 @@ func (sw *Switch) addPeer(pc peerConn) error { } // Check for duplicate connection or peer info IP. - if !sw.config.SkipDuplicatePeerIPCheck && + if !sw.config.AllowDuplicateIP && (sw.peers.HasIP(pc.RemoteIP()) || sw.peers.HasIP(peerNodeInfo.NetAddress().IP)) { return ErrSwitchDuplicatePeerIP{pc.RemoteIP()} diff --git a/p2p/switch_test.go b/p2p/switch_test.go index 74e9e9776..d33797a2b 100644 --- a/p2p/switch_test.go +++ b/p2p/switch_test.go @@ -25,6 +25,7 @@ var ( func init() { config = cfg.DefaultP2PConfig() config.PexReactor = true + config.AllowDuplicateIP = true } type PeerMessage struct { @@ -180,7 +181,7 @@ func TestConnAddrFilter(t *testing.T) { } func TestSwitchFiltersOutItself(t *testing.T) { - s1 := MakeSwitch(config, 1, "127.0.0.2", "123.123.123", initSwitchFunc) + s1 := MakeSwitch(config, 1, "127.0.0.1", "123.123.123", initSwitchFunc) // addr := s1.NodeInfo().NetAddress() // // add ourselves like we do in node.go#427 @@ -322,7 +323,7 @@ func TestSwitchReconnectsToPersistentPeer(t *testing.T) { Config: DefaultPeerConfig(), // Use different interface to prevent duplicate IP filter, this will break // beyond two peers. - listenAddr: "127.0.0.2:0", + listenAddr: "127.0.0.1:0", } rp.Start() defer rp.Stop()