Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Fix enode-address logged at program start when public IP is not known #5609

Merged
merged 3 commits into from
May 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
- Fixed: [#5562](https://github.com/ethereum/aleth/pull/5562) Don't send header request messages to peers that haven't sent us Status yet.
- Fixed: [#5581](https://github.com/ethereum/aleth/pull/5581) Fixed finding neighbour nodes in Discovery.
- Fixed: [#5599](https://github.com/ethereum/aleth/pull/5600) Prevent aleth from attempting concurrent connection to node which results in disconnect of original connection.
- Fixed: [#5609](https://github.com/ethereum/aleth/pull/5609) Log valid local enode-address when external IP is not known.

## [1.6.0] - 2019-04-16

Expand Down
6 changes: 3 additions & 3 deletions doc/private_net_sync.rst
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ Make note of the node's URL (which starts with ``enode://``) since you'll need t
Mining Beneficiary: 84258fde-b0d9-747e-b70f-f55e14831192 - 00fd4aaf9713f5bb664c20a462acc4ebc363d1a6
INFO 04-01 20:34:40 p2p info UPnP device not found.
WARN 04-01 20:34:40 p2p warn "_enabled" parameter is false, discovery is disabled
Node ID: enode://fb867844056920bbf0dd0945faff8a7a249d33726786ec367461a6c023cae62d7b2bb725a07e2f9832eb05be89e71cf81acf22022215b51a561929c37419531a@0.0.0.0:0
Node ID: enode://fb867844056920bbf0dd0945faff8a7a249d33726786ec367461a6c023cae62d7b2bb725a07e2f9832eb05be89e71cf81acf22022215b51a561929c37419531a@127.0.0.1:30303


The node should start mining blocks after a minute or two:
Expand All @@ -187,7 +187,7 @@ The node should start mining blocks after a minute or two:

--config Specify the same chain config file
--listen Specify a different port
--peerset Update the IP address in the node URL to ``127.0.0.1:<listen port>``
--peerset Specify URL of the first node
--db-path Path to save sync'd blocks. Aleth saves blocks by default to ``%APPDATA%\Ethereum`` on Windows and ``$HOME/.ethereum`` on Linux. You need to specify a different path for your second node otherwise you'll run into database access issues. See the `Common Problems`_ section for an example of this error.


Expand All @@ -208,7 +208,7 @@ The node should start mining blocks after a minute or two:
Mining Beneficiary: 84258fde-b0d9-747e-b70f-f55e14831192 - 00fd4aaf9713f5bb664c20a462acc4ebc363d1a6
INFO 04-01 20:47:59 p2p info UPnP device not found.
WARN 04-01 20:47:59 p2p warn "_enabled" parameter is false, discovery is disabled
Node ID: enode://d4a0335d481fe816a7d580a298870066c3c24af60cd1c2875bd2598befedfbd5a43942f41e04f6e92d1081de72843f15ff5fb9c8f65cb31bdce1357514f02491@0.0.0.0:0
Node ID: enode://d4a0335d481fe816a7d580a298870066c3c24af60cd1c2875bd2598befedfbd5a43942f41e04f6e92d1081de72843f15ff5fb9c8f65cb31bdce1357514f02491@127.0.0.1:30305
INFO 04-01 20:47:59 main rpc JSON-RPC socket path: \\.\pipe\\geth.ipc
JSONRPC Admin Session Key: rtsy5ehS1JA=
INFO 04-01 20:47:59 p2p sync 5def5843…|aleth/1.6.0-alpha.1-28+commit.32bb833e.dirty/windows/msvc19.0.24215.1/debug Starting full sync
Expand Down
21 changes: 19 additions & 2 deletions libp2p/Host.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,25 @@ class Host: public Worker
/// Get the public TCP endpoint.
bi::tcp::endpoint const& tcpPublic() const { return m_tcpPublic; }

/// Get the public endpoint information.
std::string enode() const { return "enode://" + id().hex() + "@" + (networkConfig().publicIPAddress.empty() ? m_tcpPublic.address().to_string() : networkConfig().publicIPAddress) + ":" + toString(m_tcpPublic.port()); }
/// Get the endpoint information.
std::string enode() const
{
std::string address;
if (!m_netConfig.publicIPAddress.empty())
address = m_netConfig.publicIPAddress;
else if (!m_tcpPublic.address().is_unspecified())
address = m_tcpPublic.address().to_string();
else
address = c_localhostIp;

std::string port;
if (m_tcpPublic.port())
port = toString(m_tcpPublic.port());
else
port = toString(m_netConfig.listenPort);

return "enode://" + id().hex() + "@" + address + ":" + port;
}

/// Get the node information.
p2p::NodeInfo nodeInfo() const { return NodeInfo(id(), (networkConfig().publicIPAddress.empty() ? m_tcpPublic.address().to_string() : networkConfig().publicIPAddress), m_tcpPublic.port(), m_clientVersion); }
Expand Down