diff --git a/endpoints-control/src/main/java/com/google/api/control/ControlFilter.java b/endpoints-control/src/main/java/com/google/api/control/ControlFilter.java index 3cef4e6..9734c54 100644 --- a/endpoints-control/src/main/java/com/google/api/control/ControlFilter.java +++ b/endpoints-control/src/main/java/com/google/api/control/ControlFilter.java @@ -370,6 +370,10 @@ private CheckRequestInfo createCheckInfo(HttpServletRequest request, String uri, apiKey = findDefaultApiKeyParam(request); } + // The Service Control check API expects IPv6 addresses formatted without brackets ('[' and ']'), so strip them. + String ipAddress = request.getRemoteAddr(); + String strippedIpAddress = ipAddress.replace("[", "").replace("]", ""); + return new CheckRequestInfo(new OperationInfo() .setApiKey(apiKey) .setApiKeyValid(!Strings.isNullOrEmpty(apiKey)) @@ -378,7 +382,7 @@ private CheckRequestInfo createCheckInfo(HttpServletRequest request, String uri, .setOperationId(nextOperationId()) .setOperationName(info.getSelector()) .setServiceName(serviceName)) - .setClientIp(request.getRemoteAddr()) + .setClientIp(strippedIpAddress) .setAndroidPackageName(request.getHeader(X_ANDROID_PACKAGE)) .setAndroidCertificateFingerprint(request.getHeader(X_ANDROID_CERT)) .setIosBundleId(request.getHeader(X_IOS_BUNDLE_ID));