diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java index d70be3c9a1..0acec45021 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java @@ -209,8 +209,14 @@ public class GraphQLHttpService { } private boolean hostIsInWhitelist(final String hostHeader) { - return config.getHostsWhitelist().stream() - .anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase())); + if (config.getHostsWhitelist().stream() + .anyMatch( + whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) { + return true; + } else { + LOG.trace("Host not in whitelist: '{}'", hostHeader); + return false; + } } public CompletableFuture stop() { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java index 951aaf3791..d674bce124 100755 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java @@ -371,8 +371,14 @@ public class JsonRpcHttpService { } private boolean hostIsInWhitelist(final String hostHeader) { - return config.getHostsWhitelist().stream() - .anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase())); + if (config.getHostsWhitelist().stream() + .anyMatch( + whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) { + return true; + } else { + LOG.trace("Host not in whitelist: '{}'", hostHeader); + return false; + } } public CompletableFuture stop() { diff --git a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java index 4a0a6ca87e..d9202d1dd7 100644 --- a/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java +++ b/metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java @@ -161,8 +161,14 @@ class MetricsHttpService implements MetricsService { } private boolean hostIsInWhitelist(final String hostHeader) { - return config.getHostsWhitelist().stream() - .anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase())); + if (config.getHostsWhitelist().stream() + .anyMatch( + whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) { + return true; + } else { + LOG.trace("Host not in whitelist: '{}'", hostHeader); + return false; + } } @Override