public abstract class MaybeAddClientAddress<T>
extends java.lang.Object
client address, possibly by looking at
"X-Forwarded-For", then the remote address of the input. This performs no DNS lookups.
This is a hack as com.github.kristofa.brave.http.HttpServerRequest is an interface and
would break api if we changed it. Moreover, this can work on non-http input types.
| Modifier | Constructor | Description |
|---|---|---|
protected |
MaybeAddClientAddress(Brave brave) |
| Modifier and Type | Method | Description |
|---|---|---|
void |
accept(T input) |
|
protected byte[] |
ipStringToBytes(java.lang.String ipString) |
Returns the
InetAddress.getAddress() having the given string representation or null if
unable to parse. |
protected abstract byte[] |
parseAddressBytes(T input) |
Returns the 4 byte ipv4 address or the 16-byte ipv6 address associated with the input type.
|
protected abstract int |
parsePort(T input) |
Returns port associated with the input or <=0 if unreadable.
|
protected MaybeAddClientAddress(Brave brave)
public final void accept(T input)
protected abstract byte[] parseAddressBytes(T input)
byte[] addressBytes = ipStringToBytes(input.getHeader("X-Forwarded-For"));
if (addressBytes == null) addressBytes = ipStringToBytes(input.getRemoteAddr());
return addressBytes;
protected abstract int parsePort(T input)
@Nullable protected byte[] ipStringToBytes(java.lang.String ipString)
InetAddress.getAddress() having the given string representation or null if
unable to parse.
This deliberately avoids all nameservice lookups (e.g. no DNS).
ipString - String containing an IPv4 or IPv6 string literal, e.g.
"192.168.0.1" or "2001:db8::1"Copyright © 2018 OpenZipkin. All rights reserved.