Log to trace denied because of host whitelisting (#663)

When we deny a connection based on HTTP hostname log to trace the
rejected value.

Signed-off-by: Danno Ferrin <danno.ferrin@gmail.com>
Co-authored-by: Usman Saleem <usman@usmans.info>
pull/689/head
Danno Ferrin 5 years ago committed by GitHub
parent d757af85b6
commit a66b244cc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLHttpService.java
  2. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/JsonRpcHttpService.java
  3. 10
      metrics/core/src/main/java/org/hyperledger/besu/metrics/prometheus/MetricsHttpService.java

@ -209,8 +209,14 @@ public class GraphQLHttpService {
} }
private boolean hostIsInWhitelist(final String hostHeader) { private boolean hostIsInWhitelist(final String hostHeader) {
return config.getHostsWhitelist().stream() if (config.getHostsWhitelist().stream()
.anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase())); .anyMatch(
whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
return true;
} else {
LOG.trace("Host not in whitelist: '{}'", hostHeader);
return false;
}
} }
public CompletableFuture<?> stop() { public CompletableFuture<?> stop() {

@ -371,8 +371,14 @@ public class JsonRpcHttpService {
} }
private boolean hostIsInWhitelist(final String hostHeader) { private boolean hostIsInWhitelist(final String hostHeader) {
return config.getHostsWhitelist().stream() if (config.getHostsWhitelist().stream()
.anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase())); .anyMatch(
whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
return true;
} else {
LOG.trace("Host not in whitelist: '{}'", hostHeader);
return false;
}
} }
public CompletableFuture<?> stop() { public CompletableFuture<?> stop() {

@ -161,8 +161,14 @@ class MetricsHttpService implements MetricsService {
} }
private boolean hostIsInWhitelist(final String hostHeader) { private boolean hostIsInWhitelist(final String hostHeader) {
return config.getHostsWhitelist().stream() if (config.getHostsWhitelist().stream()
.anyMatch(whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase())); .anyMatch(
whitelistEntry -> whitelistEntry.toLowerCase().equals(hostHeader.toLowerCase()))) {
return true;
} else {
LOG.trace("Host not in whitelist: '{}'", hostHeader);
return false;
}
} }
@Override @Override

Loading…
Cancel
Save