Browse Source

config: rename skip_upnp to upnp (#1827)

* config: rename skip_upnp to upnp

Change default option to enable upnp.

Closes #1806

* doc updates

- fix comment and set UPNP to false in TestP2PConfig
- add UPNP to config template
- update changelog
pull/1828/head
Dev Ojha 6 years ago
committed by Anton Kaliaev
parent
commit
b1d6deaf0b
9 changed files with 22 additions and 17 deletions
  1. +4
    -5
      CHANGELOG.md
  2. +1
    -1
      cmd/tendermint/commands/run_node.go
  3. +3
    -3
      config/config.go
  4. +3
    -0
      config/toml.go
  5. +3
    -0
      docs/specification/configuration.md
  6. +2
    -2
      node/node.go
  7. +3
    -3
      p2p/listener.go
  8. +1
    -1
      p2p/listener_test.go
  9. +2
    -2
      p2p/pex/pex_reactor_test.go

+ 4
- 5
CHANGELOG.md View File

@ -3,18 +3,17 @@
## TBD
BUG FIXES:
- [rpc] limited number of HTTP/WebSocket connections
(`rpc.max_open_connections`) and gRPC connections
(`rpc.grpc_max_open_connections`). Check out [Running In
Production](https://tendermint.readthedocs.io/en/master/running-in-production.html)
guide if you want to increase them.
## 0.21.2
IMPROVEMENT
BREAKING CHANGES:
- [config] Rename `skip_upnp` to `upnp`, and turn it off by default.
- [rpc/client] Supports https and wss now
IMPROVEMENT
- [rpc/client] Supports https and wss now.
## 0.21.0


+ 1
- 1
cmd/tendermint/commands/run_node.go View File

@ -33,7 +33,7 @@ func AddNodeFlags(cmd *cobra.Command) {
cmd.Flags().String("p2p.laddr", config.P2P.ListenAddress, "Node listen address. (0.0.0.0:0 means any interface, any port)")
cmd.Flags().String("p2p.seeds", config.P2P.Seeds, "Comma-delimited ID@host:port seed nodes")
cmd.Flags().String("p2p.persistent_peers", config.P2P.PersistentPeers, "Comma-delimited ID@host:port persistent peers")
cmd.Flags().Bool("p2p.skip_upnp", config.P2P.SkipUPNP, "Skip UPNP configuration")
cmd.Flags().Bool("p2p.upnp", config.P2P.UPNP, "Enable/disable UPNP port forwarding")
cmd.Flags().Bool("p2p.pex", config.P2P.PexReactor, "Enable/disable Peer-Exchange")
cmd.Flags().Bool("p2p.seed_mode", config.P2P.SeedMode, "Enable/disable seed mode")
cmd.Flags().String("p2p.private_peer_ids", config.P2P.PrivatePeerIDs, "Comma-delimited private peer IDs")


+ 3
- 3
config/config.go View File

@ -284,8 +284,8 @@ type P2PConfig struct {
// Do not add private peers to this list if you don't want them advertised
PersistentPeers string `mapstructure:"persistent_peers"`
// Skip UPNP port forwarding
SkipUPNP bool `mapstructure:"skip_upnp"`
// UPNP port forwarding
UPNP bool `mapstructure:"upnp"`
// Path to address book
AddrBook string `mapstructure:"addr_book_file"`
@ -341,6 +341,7 @@ type P2PConfig struct {
func DefaultP2PConfig() *P2PConfig {
return &P2PConfig{
ListenAddress: "tcp://0.0.0.0:26656",
UPNP: false,
AddrBook: defaultAddrBookPath,
AddrBookStrict: true,
MaxNumPeers: 50,
@ -363,7 +364,6 @@ func DefaultP2PConfig() *P2PConfig {
func TestP2PConfig() *P2PConfig {
cfg := DefaultP2PConfig()
cfg.ListenAddress = "tcp://0.0.0.0:36656"
cfg.SkipUPNP = true
cfg.FlushThrottleTimeout = 10
cfg.AllowDuplicateIP = true
return cfg


+ 3
- 0
config/toml.go View File

@ -149,6 +149,9 @@ seeds = "{{ .P2P.Seeds }}"
# Do not add private peers to this list if you don't want them advertised
persistent_peers = "{{ .P2P.PersistentPeers }}"
# UPNP port forwarding
upnp = {{ .P2P.UPNP }}
# Path to address book
addr_book_file = "{{ js .P2P.AddrBook }}"


+ 3
- 0
docs/specification/configuration.md View File

@ -103,6 +103,9 @@ seeds = ""
# Do not add private peers to this list if you don't want them advertised
persistent_peers = ""
# UPNP port forwarding
upnp = false
# Path to address book
addr_book_file = "addrbook.json"


+ 2
- 2
node/node.go View File

@ -10,8 +10,8 @@ import (
"github.com/prometheus/client_golang/prometheus/promhttp"
abci "github.com/tendermint/tendermint/abci/types"
amino "github.com/tendermint/go-amino"
abci "github.com/tendermint/tendermint/abci/types"
cmn "github.com/tendermint/tmlibs/common"
dbm "github.com/tendermint/tmlibs/db"
"github.com/tendermint/tmlibs/log"
@ -427,7 +427,7 @@ func (n *Node) OnStart() error {
// Create & add listener
protocol, address := cmn.ProtocolAndAddress(n.config.P2P.ListenAddress)
l := p2p.NewDefaultListener(protocol, address, n.config.P2P.SkipUPNP, n.Logger.With("module", "p2p"))
l := p2p.NewDefaultListener(protocol, address, n.config.P2P.UPNP, n.Logger.With("module", "p2p"))
n.sw.AddListener(l)
// Generate node PrivKey


+ 3
- 3
p2p/listener.go View File

@ -47,8 +47,8 @@ func splitHostPort(addr string) (host string, port int) {
return host, port
}
// skipUPNP: If true, does not try getUPNPExternalAddress()
func NewDefaultListener(protocol string, lAddr string, skipUPNP bool, logger log.Logger) Listener {
// UPNP: If false, does not try getUPNPExternalAddress()
func NewDefaultListener(protocol string, lAddr string, UPNP bool, logger log.Logger) Listener {
// Local listen IP & port
lAddrIP, lAddrPort := splitHostPort(lAddr)
@ -79,7 +79,7 @@ func NewDefaultListener(protocol string, lAddr string, skipUPNP bool, logger log
// Determine external address...
var extAddr *NetAddress
if !skipUPNP {
if UPNP {
// If the lAddrIP is INADDR_ANY, try UPnP
if lAddrIP == "" || lAddrIP == "0.0.0.0" {
extAddr = getUPNPExternalAddress(lAddrPort, listenerPort, logger)


+ 1
- 1
p2p/listener_test.go View File

@ -9,7 +9,7 @@ import (
func TestListener(t *testing.T) {
// Create a listener
l := NewDefaultListener("tcp", ":8001", true, log.TestingLogger())
l := NewDefaultListener("tcp", ":8001", false, log.TestingLogger())
// Dial the listener
lAddr := l.ExternalAddress()


+ 2
- 2
p2p/pex/pex_reactor_test.go View File

@ -109,7 +109,7 @@ func TestPEXReactorRunning(t *testing.T) {
addOtherNodeAddrToAddrBook(2, 1)
for i, sw := range switches {
sw.AddListener(p2p.NewDefaultListener("tcp", sw.NodeInfo().ListenAddr, true, logger.With("pex", i)))
sw.AddListener(p2p.NewDefaultListener("tcp", sw.NodeInfo().ListenAddr, false, logger.With("pex", i)))
err := sw.Start() // start switch and reactors
require.Nil(t, err)
@ -232,7 +232,7 @@ func TestPEXReactorUsesSeedsIfNeeded(t *testing.T) {
p2p.NewDefaultListener(
"tcp",
seed.NodeInfo().ListenAddr,
true,
false,
log.TestingLogger(),
),
)


Loading…
Cancel
Save