Sentinel匹配的Client IP策略(基于Gateway网关)

Sentinel匹配的Client IP策略


GatewayParamParser对象中parseClientIp()

private String parseClientIp(GatewayParamFlowItem item, T request) {
        String clientIp = this.requestItemParser.getRemoteAddress(request);
        String pattern = item.getPattern();
        return StringUtil.isEmpty(pattern) ? clientIp : this.parseWithMatchStrategyInternal(item.getMatchStrategy(), clientIp, pattern);
    }

ServerWebExchangeItemParser的getRemoteAddress()

public String getRemoteAddress(ServerWebExchange exchange) {
        InetSocketAddress remoteAddress = exchange.getRequest().getRemoteAddress();
        return remoteAddress == null ? null : remoteAddress.getAddress().getHostAddress();
    }

你可能感兴趣的:(微服务,spring,cloud,gateway,Sentinel,Gateway)