From a15a9577f0526dcb50d17b23f26ea437d5952f80 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 30 Jun 2022 15:41:44 +0300 Subject: [PATCH 1/2] docs: fix wrong default address value mentioned We're listening on all addresses by default. --- docs/node-configuration.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/node-configuration.md b/docs/node-configuration.md index 809eb4a2c..9659b2744 100644 --- a/docs/node-configuration.md +++ b/docs/node-configuration.md @@ -16,7 +16,7 @@ node-related settings described in the table below. | Section | Type | Default value | Description | | --- | --- | --- | --- | -| Address | `string` | `127.0.0.1` | Node address that P2P protocol handler binds to. | +| Address | `string` | `0.0.0.0` | Node address that P2P protocol handler binds to. | | AnnouncedPort | `uint16` | Same as `NodePort` | Node port which should be used to announce node's port on P2P layer, it can differ from the `NodePort` the node is bound to (for example, if your node is behind NAT). | | AttemptConnPeers | `int` | `20` | Number of connection to try to establish when the connection count drops below the `MinPeers` value.| | DBConfiguration | [DB Configuration](#DB-Configuration) | | Describes configuration for database. See the [DB Configuration](#DB-Configuration) section for details. | From c26a962b55cf6b8438279efe8239ab357a7e3e6e Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Thu, 30 Jun 2022 16:18:41 +0300 Subject: [PATCH 2/2] *: use localhost address instead of 127.0.0.1, fix #2575 --- cli/server/server_test.go | 4 ++-- config/protocol.mainnet.yml | 2 +- config/protocol.privnet.docker.four.yml | 2 +- config/protocol.privnet.docker.one.yml | 2 +- config/protocol.privnet.docker.single.yml | 2 +- config/protocol.privnet.docker.three.yml | 2 +- config/protocol.privnet.docker.two.yml | 2 +- config/protocol.privnet.yml | 10 +++++----- config/protocol.testnet.yml | 2 +- config/protocol.unit_testnet.single.yml | 4 ++-- config/protocol.unit_testnet.yml | 10 +++++----- pkg/network/payload/address_test.go | 4 ++-- pkg/network/server_config.go | 2 +- 13 files changed, 24 insertions(+), 24 deletions(-) diff --git a/cli/server/server_test.go b/cli/server/server_test.go index 99d523d03..30d7edb6c 100644 --- a/cli/server/server_test.go +++ b/cli/server/server_test.go @@ -288,8 +288,8 @@ func TestRestoreDB(t *testing.T) { } func TestConfigureAddresses(t *testing.T) { - defaultAddress := "http://127.0.0.1:10333" - customAddress := "http://127.0.0.1:10334" + defaultAddress := "http://localhost:10333" + customAddress := "http://localhost:10334" t.Run("default addresses", func(t *testing.T) { cfg := &config.ApplicationConfiguration{ diff --git a/config/protocol.mainnet.yml b/config/protocol.mainnet.yml index 3de5312c3..5325d6afe 100644 --- a/config/protocol.mainnet.yml +++ b/config/protocol.mainnet.yml @@ -60,7 +60,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/mainnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 10333 Relay: true DialTimeout: 3 diff --git a/config/protocol.privnet.docker.four.yml b/config/protocol.privnet.docker.four.yml index 0dda142e0..41a563f76 100644 --- a/config/protocol.privnet.docker.four.yml +++ b/config/protocol.privnet.docker.four.yml @@ -39,7 +39,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/privnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20336 Relay: true DialTimeout: 3 diff --git a/config/protocol.privnet.docker.one.yml b/config/protocol.privnet.docker.one.yml index 09e46e4d8..277585598 100644 --- a/config/protocol.privnet.docker.one.yml +++ b/config/protocol.privnet.docker.one.yml @@ -39,7 +39,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/privnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20333 Relay: true DialTimeout: 3 diff --git a/config/protocol.privnet.docker.single.yml b/config/protocol.privnet.docker.single.yml index 3baec517f..5edc79742 100644 --- a/config/protocol.privnet.docker.single.yml +++ b/config/protocol.privnet.docker.single.yml @@ -33,7 +33,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/privnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20333 Relay: true DialTimeout: 3 diff --git a/config/protocol.privnet.docker.three.yml b/config/protocol.privnet.docker.three.yml index 2dc2b3a6a..ae02382ef 100644 --- a/config/protocol.privnet.docker.three.yml +++ b/config/protocol.privnet.docker.three.yml @@ -39,7 +39,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/privnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20335 Relay: true DialTimeout: 3 diff --git a/config/protocol.privnet.docker.two.yml b/config/protocol.privnet.docker.two.yml index fee6455bb..4e78e8a43 100644 --- a/config/protocol.privnet.docker.two.yml +++ b/config/protocol.privnet.docker.two.yml @@ -39,7 +39,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/privnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20334 Relay: true DialTimeout: 3 diff --git a/config/protocol.privnet.yml b/config/protocol.privnet.yml index 5756eee92..8a9651197 100644 --- a/config/protocol.privnet.yml +++ b/config/protocol.privnet.yml @@ -10,10 +10,10 @@ ProtocolConfiguration: - 02a7bc55fe8684e0119768d104ba30795bdcc86619e864add26156723ed185cd62 ValidatorsCount: 4 SeedList: - - 127.0.0.1:20333 - - 127.0.0.1:20334 - - 127.0.0.1:20335 - - 127.0.0.1:20336 + - localhost:20333 + - localhost:20334 + - localhost:20335 + - localhost:20336 VerifyBlocks: true VerifyTransactions: true P2PSigExtensions: false @@ -39,7 +39,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/privnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20332 Relay: true DialTimeout: 3 diff --git a/config/protocol.testnet.yml b/config/protocol.testnet.yml index 5a086e077..c5cc9ec0f 100644 --- a/config/protocol.testnet.yml +++ b/config/protocol.testnet.yml @@ -63,7 +63,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/testnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20333 Relay: true DialTimeout: 3 diff --git a/config/protocol.unit_testnet.single.yml b/config/protocol.unit_testnet.single.yml index 6bb8f6238..889b477bf 100644 --- a/config/protocol.unit_testnet.single.yml +++ b/config/protocol.unit_testnet.single.yml @@ -34,7 +34,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/unit_testnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 0 Relay: true DialTimeout: 3 @@ -53,7 +53,7 @@ ApplicationConfiguration: Path: "/notary_wallet.json" Password: "pass" RPC: - Address: 127.0.0.1 + Address: localhost MaxGasInvoke: 15 Enabled: true EnableCORSWorkaround: false diff --git a/config/protocol.unit_testnet.yml b/config/protocol.unit_testnet.yml index bb3017ee7..8d865bd51 100644 --- a/config/protocol.unit_testnet.yml +++ b/config/protocol.unit_testnet.yml @@ -12,9 +12,9 @@ ProtocolConfiguration: - 02c4de32252c50fa171dbe25379e4e2d55cdc12f69e382c39f59a44573ecff2f9d ValidatorsCount: 4 SeedList: - - 127.0.0.1:20334 - - 127.0.0.1:20335 - - 127.0.0.1:20336 + - localhost:20334 + - localhost:20335 + - localhost:20336 VerifyBlocks: true VerifyTransactions: true P2PSigExtensions: true @@ -43,7 +43,7 @@ ApplicationConfiguration: # BoltDBOptions: # FilePath: "./chains/unit_testnet.bolt" # Uncomment in order to set up custom address for node. - # Address: 127.0.0.1 + # Address: localhost NodePort: 20333 Relay: true DialTimeout: 3 @@ -59,7 +59,7 @@ ApplicationConfiguration: Path: "/notary_wallet.json" Password: "pass" RPC: - Address: 127.0.0.1 + Address: localhost MaxGasInvoke: 15 Enabled: true EnableCORSWorkaround: false diff --git a/pkg/network/payload/address_test.go b/pkg/network/payload/address_test.go index 4bf58d0b6..843aeecc0 100644 --- a/pkg/network/payload/address_test.go +++ b/pkg/network/payload/address_test.go @@ -14,7 +14,7 @@ import ( func TestEncodeDecodeAddress(t *testing.T) { var ( - e, _ = net.ResolveTCPAddr("tcp", "127.0.0.1:2000") + e, _ = net.ResolveTCPAddr("tcp", "localhost:2000") ts = time.Now() addr = NewAddressAndTime(e, ts, capability.Capabilities{ { @@ -39,7 +39,7 @@ func TestEncodeDecodeAddress(t *testing.T) { func fillAddressList(al *AddressList) { for i := 0; i < len(al.Addrs); i++ { - e, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("127.0.0.1:20%d", i)) + e, _ := net.ResolveTCPAddr("tcp", fmt.Sprintf("localhost:20%d", i)) al.Addrs[i] = NewAddressAndTime(e, time.Now(), capability.Capabilities{ { Type: capability.TCPServer, diff --git a/pkg/network/server_config.go b/pkg/network/server_config.go index a415dde6e..4bfdfb4b8 100644 --- a/pkg/network/server_config.go +++ b/pkg/network/server_config.go @@ -28,7 +28,7 @@ type ( // The user agent of the server. UserAgent string - // Address. Example: "127.0.0.1". + // Address. Example: "localhost". Address string // AnnouncedPort is an announced node port for P2P version exchange.