code: public String ip() {
          Boolean trustProxy = (Boolean) context.get("trust-proxy");
          if (trustProxy != null && trustProxy) {
              String xForwardFor = getHeader("x-forward-for");
              if (xForwardFor != null) {
                  String[] ips = xForwardFor.split(" *, *");
                  if (ips.length > 0) {
                      return ips[0];
                  }
              }
          }
  
          return request.remoteAddress().host();
      }
docs: Returns the ip address of the client, when trust-proxy is true (default) then first look into X-Forward-For
  Header