diff --git a/proxy/deploy-proxy-for-env.sh b/proxy/deploy-proxy-for-env.sh index 9d425af14..a20c53b6d 100755 --- a/proxy/deploy-proxy-for-env.sh +++ b/proxy/deploy-proxy-for-env.sh @@ -40,7 +40,8 @@ do kubectl apply -f - kubectl apply -f "./kubernetes/proxy-service-canary.yaml" --force fi - # Kills all running pods, new pods created will be pulling the new image. - kubectl delete pods --all + # Restart all running pods, new pods created will be pulling the new image. + kubectl rollout restart deployment/proxy-deployment + kubectl rollout restart deployment/proxy-deployment-canary done < <(gcloud container clusters list --project ${project} | grep proxy-cluster) kubectl config use-context "$current_context" diff --git a/proxy/src/main/java/google/registry/proxy/handler/WhoisServiceHandler.java b/proxy/src/main/java/google/registry/proxy/handler/WhoisServiceHandler.java index 669872564..6f670b958 100644 --- a/proxy/src/main/java/google/registry/proxy/handler/WhoisServiceHandler.java +++ b/proxy/src/main/java/google/registry/proxy/handler/WhoisServiceHandler.java @@ -15,8 +15,10 @@ package google.registry.proxy.handler; import static com.google.common.base.Preconditions.checkArgument; +import static google.registry.proxy.handler.ProxyProtocolHandler.REMOTE_ADDRESS_KEY; import google.registry.proxy.metric.FrontendMetrics; +import google.registry.util.ProxyHttpHeaders; import io.netty.buffer.ByteBuf; import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelHandlerContext; @@ -30,6 +32,8 @@ import java.util.function.Supplier; /** Handler that processes WHOIS protocol logic. */ public final class WhoisServiceHandler extends HttpsRelayServiceHandler { + private String clientAddress; + public WhoisServiceHandler( String relayHost, String relayPath, @@ -45,6 +49,12 @@ public final class WhoisServiceHandler extends HttpsRelayServiceHandler { super.channelActive(ctx); } + @Override + public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception { + clientAddress = ctx.channel().attr(REMOTE_ADDRESS_KEY).get(); + super.channelRead(ctx, msg); + } + @Override protected FullHttpRequest decodeFullHttpRequest(ByteBuf byteBuf) { FullHttpRequest request = super.decodeFullHttpRequest(byteBuf); @@ -52,6 +62,12 @@ public final class WhoisServiceHandler extends HttpsRelayServiceHandler { .headers() .set(HttpHeaderNames.CONTENT_TYPE, HttpHeaderValues.TEXT_PLAIN) .set(HttpHeaderNames.ACCEPT, HttpHeaderValues.TEXT_PLAIN); + if (clientAddress != null) { + request + .headers() + .set(ProxyHttpHeaders.IP_ADDRESS, clientAddress) + .set(ProxyHttpHeaders.FALLBACK_IP_ADDRESS, clientAddress); + } return request; }