diff --git a/blocksync/blocksync_test.go b/blocksync/blocksync_test.go index d4fbaef0d6..4ac3291899 100644 --- a/blocksync/blocksync_test.go +++ b/blocksync/blocksync_test.go @@ -61,7 +61,7 @@ func TestSyncTaskInterval(t *testing.T) { func generateP2P() network.Overlay { c := &config.Network{ - IP: "127.0.0.1", + Host: "127.0.0.1", Port: 10001, MsgLogsCleaningInterval: 2 * time.Second, MsgLogRetention: 10 * time.Second, @@ -70,7 +70,7 @@ func generateP2P() network.Overlay { PeerMaintainerInterval: time.Second, NumPeersLowerBound: 5, NumPeersUpperBound: 5, - AllowMultiConnsPerIP: true, + AllowMultiConnsPerHost: true, RateLimitEnabled: false, PingInterval: time.Second, BootstrapNodes: []string{"127.0.0.1:10001", "127.0.0.1:10002"}, @@ -321,7 +321,7 @@ func newTestConfig() (*config.Config, error) { cfg.Chain.ChainDBPath = "db.test" cfg.BlockSync.Interval = time.Millisecond << 4 cfg.Consensus.Scheme = config.NOOPScheme - cfg.Network.IP = "127.0.0.1" + cfg.Network.Host = "127.0.0.1" cfg.Network.Port = 10000 cfg.Network.BootstrapNodes = []string{"127.0.0.1:10000", "127.0.0.1:4689"} return &cfg, nil diff --git a/config/config.go b/config/config.go index 3da0bb2403..211d21b709 100644 --- a/config/config.go +++ b/config/config.go @@ -56,14 +56,14 @@ var ( Default = Config{ NodeType: FullNodeType, Network: Network{ - IP: "127.0.0.1", + Host: "127.0.0.1", Port: 4689, MsgLogsCleaningInterval: 2 * time.Second, MsgLogRetention: 5 * time.Second, HealthCheckInterval: time.Second, SilentInterval: 5 * time.Second, PeerMaintainerInterval: time.Second, - AllowMultiConnsPerIP: false, + AllowMultiConnsPerHost: false, NumPeersLowerBound: 5, NumPeersUpperBound: 5, PingInterval: time.Second, @@ -152,14 +152,14 @@ var ( // Network is the config struct for network package type ( Network struct { - IP string `yaml:"ip"` + Host string `yaml:"host"` Port int `yaml:"port"` MsgLogsCleaningInterval time.Duration `yaml:"msgLogsCleaningInterval"` MsgLogRetention time.Duration `yaml:"msgLogRetention"` HealthCheckInterval time.Duration `yaml:"healthCheckInterval"` SilentInterval time.Duration `yaml:"silentInterval"` PeerMaintainerInterval time.Duration `yaml:"peerMaintainerInterval"` - AllowMultiConnsPerIP bool `yaml:"allowMultiConnsPerIP"` + AllowMultiConnsPerHost bool `yaml:"allowMultiConnsPerHost"` NumPeersLowerBound uint `yaml:"numPeersLowerBound"` NumPeersUpperBound uint `yaml:"numPeersUpperBound"` PingInterval time.Duration `yaml:"pingInterval"` diff --git a/e2etest/config_local_delegate.yaml b/e2etest/config_local_delegate.yaml index 29a29e90bd..89bd79bc3a 100644 --- a/e2etest/config_local_delegate.yaml +++ b/e2etest/config_local_delegate.yaml @@ -4,7 +4,7 @@ nodeType: "delegate" # should be one of "delegate", "full_node", and "lightweight" network: - ip: "127.0.0.1" + host: "127.0.0.1" port: 4689 bootstrapNodes: - "127.0.0.1:4689" diff --git a/e2etest/net_test.go b/e2etest/net_test.go index df9c579ce1..e9ca1888cc 100644 --- a/e2etest/net_test.go +++ b/e2etest/net_test.go @@ -30,7 +30,7 @@ func TestNetSync(t *testing.T) { defer testutil.CleanupPath(t, testDBPath) cfg := config.Default - cfg.Network.IP = "127.0.0.1" + cfg.Network.Host = "127.0.0.1" cfg.Network.Port = 10000 cfg.Network.BootstrapNodes = []string{"127.0.0.1:4689"} cfg.Chain.TrieDBPath = testTriePath diff --git a/network/overlay_test.go b/network/overlay_test.go index 9cd0dc15fa..95f041daa0 100644 --- a/network/overlay_test.go +++ b/network/overlay_test.go @@ -31,19 +31,19 @@ import ( "github.com/iotexproject/iotex-core/testutil" ) -func LoadTestConfig(addr string, allowMultiConnsPerIP bool) *config.Network { +func LoadTestConfig(addr string, allowMultiConnsPerHost bool) *config.Network { var ( - ip = "127.0.0.1" + host = "127.0.0.1" port int ) if addrComp := strings.Split(addr, ":"); len(addrComp) == 2 { - ip = addrComp[0] + host = addrComp[0] port, _ = strconv.Atoi(addrComp[1]) } config := config.Config{ NodeType: config.DelegateType, Network: config.Network{ - IP: ip, + Host: host, Port: port, MsgLogsCleaningInterval: 2 * time.Second, MsgLogRetention: 10 * time.Second, @@ -52,7 +52,7 @@ func LoadTestConfig(addr string, allowMultiConnsPerIP bool) *config.Network { PeerMaintainerInterval: time.Second, NumPeersLowerBound: 5, NumPeersUpperBound: 5, - AllowMultiConnsPerIP: allowMultiConnsPerIP, + AllowMultiConnsPerHost: allowMultiConnsPerHost, RateLimitEnabled: false, PingInterval: time.Second, BootstrapNodes: []string{"127.0.0.1:10001", "127.0.0.1:10002"}, @@ -64,8 +64,8 @@ func LoadTestConfig(addr string, allowMultiConnsPerIP bool) *config.Network { return &config.Network } -func LoadTestConfigWithTLSEnabled(addr string, allowMultiConnsPerIP bool) *config.Network { - cfg := LoadTestConfig(addr, allowMultiConnsPerIP) +func LoadTestConfigWithTLSEnabled(addr string, allowMultiConnsPerHost bool) *config.Network { + cfg := LoadTestConfig(addr, allowMultiConnsPerHost) cfg.TLSEnabled = true cfg.CACrtPath = "../test/assets/ssl/iotex.io.crt" cfg.PeerCrtPath = "../test/assets/ssl/127.0.0.1.crt" @@ -214,7 +214,7 @@ func TestTell(t *testing.T) { require.Nil(t, err) } -func TestOneConnPerIP(t *testing.T) { +func TestOneConnPerHost(t *testing.T) { ctx := context.Background() dp1 := &MockDispatcher2{T: t} addr1 := randomAddress() diff --git a/network/peermanager.go b/network/peermanager.go index e62a311131..091fd7f6ae 100644 --- a/network/peermanager.go +++ b/network/peermanager.go @@ -49,7 +49,7 @@ func (pm *PeerManager) AddPeer(addr string) { Msg("Node at address is already the peer") return } - if !pm.Overlay.Config.AllowMultiConnsPerIP { + if !pm.Overlay.Config.AllowMultiConnsPerHost { nHost, _, err := net.SplitHostPort(addr) if err != nil { logger.Error(). @@ -76,7 +76,7 @@ func (pm *PeerManager) AddPeer(addr string) { if found { logger.Debug(). Str("nHost", nHost). - Msg("Another node on the same IP is already the peer") + Msg("Another node on the same Host is already the peer") return } } diff --git a/network/rpcserver.go b/network/rpcserver.go index f70969ae10..b6946a6ddc 100644 --- a/network/rpcserver.go +++ b/network/rpcserver.go @@ -45,7 +45,7 @@ type RPCServer struct { func NewRPCServer(o *IotxOverlay) *RPCServer { s := &RPCServer{Overlay: o} portStr := strconv.Itoa(o.Config.Port) - s.Addr = strings.Join([]string{o.Config.IP, portStr}, ":") + s.Addr = strings.Join([]string{o.Config.Host, portStr}, ":") s.rateLimit = o.Config.RateLimitPerSec * uint64(o.Config.RateLimitWindowSize) / uint64(time.Second) return s } diff --git a/simulator/consensus_sim_server.go b/simulator/consensus_sim_server.go index e33b93c858..ad7e1566da 100644 --- a/simulator/consensus_sim_server.go +++ b/simulator/consensus_sim_server.go @@ -80,7 +80,7 @@ func (s *server) Init(in *pb.InitRequest, stream pb.Simulator_InitServer) error cfg.Consensus.RollDPoS.AcceptVoteTTL = 1000 * time.Second // handle node address, delegate addresses, etc. - cfg.Network.IP = "127.0.0.1" + cfg.Network.Host = "127.0.0.1" cfg.Network.Port = 10000 cfg.Network.NumPeersLowerBound = 6 cfg.Network.NumPeersUpperBound = 12