org.glassfish.grizzly.http.server.Request.getRemoteAddr()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(5.8k)|赞(0)|评价(0)|浏览(244)

本文整理了Java中org.glassfish.grizzly.http.server.Request.getRemoteAddr方法的一些代码示例,展示了Request.getRemoteAddr的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getRemoteAddr方法的具体详情如下:
包路径:org.glassfish.grizzly.http.server.Request
类名称:Request
方法名:getRemoteAddr

Request.getRemoteAddr介绍

[英]Return the remote IP address making this Request.
[中]返回发出此请求的远程IP地址。

代码示例

代码示例来源:origin: Graylog2/graylog2-server

/**
 * If X-Forwarded-For request header is set, and the request came from a trusted source,
 * return the value of X-Forwarded-For. Otherwise return {@link Request#getRemoteAddr()}.
 */
public static String getRemoteAddrFromRequest(Request request, Set<IpSubnet> trustedSubnets) {
  final String remoteAddr = request.getRemoteAddr();
  final String XForwardedFor = request.getHeader("X-Forwarded-For");
  if (XForwardedFor != null) {
    for (IpSubnet s : trustedSubnets) {
      try {
        if (s.contains(remoteAddr)) {
          // Request came from trusted source, trust X-Forwarded-For and return it
          return XForwardedFor;
        }
      } catch (UnknownHostException e) {
        // ignore silently, probably not worth logging
      }
    }
  }
  // Request did not come from a trusted source, or the X-Forwarded-For header was not set
  return remoteAddr;
}

代码示例来源:origin: apache/incubator-pinot

@Override
 public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext)
   throws IOException {
  final String method = requestContext.getMethod();
  final String uri = requestContext.getUriInfo().getRequestUri().toString();
  final int respStatus = responseContext.getStatus();
  final String reasonPhrase = responseContext.getStatusInfo().getReasonPhrase();
  final String srcIpAddr = request.get().getRemoteAddr();
  final String contentType = requestContext.getHeaderString(HttpHeaders.CONTENT_TYPE);
  LOGGER.info("Handled request from {} {} {}, content-type {} status code {} {}", srcIpAddr, method, uri, contentType,
    respStatus, reasonPhrase);
 }
}

代码示例来源:origin: Graylog2/graylog2-server

SecurityContext.BASIC_AUTH,
host,
grizzlyRequest.getRemoteAddr(),
headers);
grizzlyRequest.getRemoteAddr(),
headers);

代码示例来源:origin: opentripplanner/OpenTripPlanner

String clientIpAddress = grizzlyRequest.getRemoteAddr();

代码示例来源:origin: apache/incubator-pinot

String clientAddress = InetAddress.getByName(request.getRemoteAddr()).getHostName();
String segmentName = segmentMetadata.getName();
String offlineTableName = TableNameBuilder.OFFLINE.tableNameWithType(segmentMetadata.getTableName());

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server-core

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: javaee/grizzly

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: javaee/grizzly

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: javaee/grizzly

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: javaee/grizzly

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: javaee/grizzly

/**
 * {@inheritDoc}
 */
@Override
public String getRemoteAddr() {
  if (request == null) {
    throw new IllegalStateException("Null request object");
  }
  return request.getRemoteAddr();
}

代码示例来源:origin: javaee/grizzly

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: javaee/grizzly

/**
 * {@inheritDoc}
 */
@Override
public String getRemoteAddr() {
  if (request == null) {
    throw new IllegalStateException("Null request object");
  }
  return request.getRemoteAddr();
}

代码示例来源:origin: javaee/grizzly

/**
 * {@inheritDoc}
 */
@Override
public String getRemoteAddr() {
  if (request == null) {
    throw new IllegalStateException("Null request object");
  }
  return request.getRemoteAddr();
}

代码示例来源:origin: org.mule.glassfish.grizzly/grizzly-http-server

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-http-server

@Override
  StringBuilder format(StringBuilder builder, Request request, Response response, Date timeStamp, long responseNanos) {
    final String address = request.getRemoteAddr();
    return builder.append(address == null ? "-" : address);
  }
}

代码示例来源:origin: org.glassfish.grizzly/grizzly-websockets-server

/**
 * {@inheritDoc}
 */
@Override
public String getRemoteAddr() {
  if (request == null) {
    throw new IllegalStateException("Null request object");
  }
  return request.getRemoteAddr();
}

代码示例来源:origin: javaee/grizzly

/**
 * {@inheritDoc}
 */
@Override
public String getRemoteAddr() {
  if (request == null) {
    throw new IllegalStateException("Null request object");
  }
  return request.getRemoteAddr();
}

代码示例来源:origin: javaee/grizzly

/**
 * {@inheritDoc}
 */
@Override
public String getRemoteAddr() {
  if (request == null) {
    throw new IllegalStateException("Null request object");
  }
  return request.getRemoteAddr();
}

相关文章

Request类方法