resolve method

DVIpAddress? resolve(
  1. Object? request
)

The client address of request, or null when it has no peer address.

Implementation

DVIpAddress? resolve(Object? request) {
  final DVIpAddress? peer = peerOf(request)?.address;
  if (peer == null) return null;
  if (!trusts(peer)) return peer;

  final List<DVIpAddress?> hops = _hops(_headerValues(request));
  DVIpAddress client = peer;
  final int stop = hops.length > maxHops ? hops.length - maxHops : 0;
  for (int i = hops.length - 1; i >= stop; i--) {
    final DVIpAddress? hop = hops[i];
    if (hop == null) return client;
    client = hop;
    if (!trusts(hop)) return hop;
  }
  return client;
}