Skip to content

Commit

Permalink
Merge pull request #1853 from rsksmart/public_ip_detection_quickfix
Browse files Browse the repository at this point in the history
Added fallback dummy IP to Public IP discovery service
  • Loading branch information
Vovchyk authored Sep 16, 2022
2 parents 3702ea8 + 2e8cb68 commit c3c9f25
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -499,11 +499,17 @@ private InetAddress getMyPublicIpFromRemoteService() {
}

InetAddress bindAddress = getBindAddress();
if (bindAddress.isAnyLocalAddress()) {
throw new RuntimeException("Wildcard on bind address it's not allowed as fallback for public IP " + bindAddress);
if (!bindAddress.isAnyLocalAddress()) {
return bindAddress;
}

return bindAddress;
try {
// workaround to provide a last resort fallback to calculate node's public IP
// this value is safe because it is not being used in any of the protocols; however, once we implement a better solution to identify actual public IP, this fallback should be removed
return InetAddress.getByName("127.0.0.1");
} catch (UnknownHostException e) {
throw new IllegalStateException("Could not provide a public IP", e);
}
}

private URL publicIpCheckService() throws MalformedURLException {
Expand Down
3 changes: 3 additions & 0 deletions rskj-core/src/main/resources/reference.conf
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ public {

# The URL of a service returning our own public IP as the response body.
# If multiple IPs are returned separated by commas (e.g Amazon returns X-Forwarded-For values) the last one is used
# We have two fallback mechanisms in case this service is not working, in order of precedence:
# 1) use bind_address property (only if not local)
# 2) use hardcoded address "127.0.0.1" as last resort
ipCheckService = "https://checkip.amazonaws.com"
}

Expand Down

0 comments on commit c3c9f25

Please sign in to comment.