From a54e790f44f6fb8f7cccbb793ce8827ea9c07273 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Mon, 18 Nov 2024 15:56:49 +1100 Subject: [PATCH 1/2] Fix HttpServletRequest.getRemoteAddr for the HttpConnector mode Signed-off-by: Lachlan Roberts --- .../jetty/http/JettyRequestAPIData.java | 25 +++++ .../runtime/jetty9/JettyRequestAPIData.java | 39 ++++++- .../runtime/jetty9/RemoteAddressTest.java | 101 ++++++++++++++++++ .../jetty9/gzipapp/EE10EchoServlet.java | 1 - .../jetty9/gzipapp/EE8EchoServlet.java | 1 - .../remoteaddrapp/EE10RemoteAddrServlet.java | 37 +++++++ .../remoteaddrapp/EE8RemoteAddrServlet.java | 37 +++++++ .../gzipapp/jetty94/WEB-INF/appengine-web.xml | 2 +- .../ee10/WEB-INF/appengine-web.xml | 25 +++++ .../jetty9/remoteaddrapp/ee10/WEB-INF/web.xml | 32 ++++++ .../ee8/WEB-INF/appengine-web.xml | 25 +++++ .../jetty9/remoteaddrapp/ee8/WEB-INF/web.xml | 32 ++++++ .../jetty94/WEB-INF/appengine-web.xml | 26 +++++ .../remoteaddrapp/jetty94/WEB-INF/web.xml | 32 ++++++ 14 files changed, 409 insertions(+), 6 deletions(-) create mode 100644 runtime/test/src/test/java/com/google/apphosting/runtime/jetty9/RemoteAddressTest.java create mode 100644 runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE10RemoteAddrServlet.java create mode 100644 runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE8RemoteAddrServlet.java create mode 100644 runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/appengine-web.xml create mode 100644 runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/web.xml create mode 100644 runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/appengine-web.xml create mode 100644 runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/web.xml create mode 100644 runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/appengine-web.xml create mode 100644 runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/web.xml diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java index 8a3d79625..c8375394d 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java @@ -59,6 +59,8 @@ import com.google.apphosting.runtime.jetty.AppInfoFactory; import com.google.common.base.Strings; import com.google.common.flogger.GoogleLogger; +import java.net.InetSocketAddress; +import java.net.SocketAddress; import java.time.Duration; import java.util.Objects; import java.util.stream.Stream; @@ -66,7 +68,9 @@ import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpScheme; import org.eclipse.jetty.http.HttpURI; +import org.eclipse.jetty.server.ConnectionMetaData; import org.eclipse.jetty.server.Request; +import org.eclipse.jetty.util.HostPort; /** * Implementation for the {@link RequestAPIData} to allow for the Jetty {@link Request} to be used @@ -274,6 +278,7 @@ public JettyRequestAPIData( traceContext = com.google.apphosting.base.protos.TracePb.TraceContextProto.getDefaultInstance(); + String finalUserIp = userIp; this.originalRequest = request; this.request = new Request.Wrapper(request) { @@ -291,6 +296,26 @@ public boolean isSecure() { public HttpFields getHeaders() { return fields; } + + @Override + public ConnectionMetaData getConnectionMetaData() { + return new ConnectionMetaData.Wrapper(super.getConnectionMetaData()) { + @Override + public SocketAddress getRemoteSocketAddress() { + return InetSocketAddress.createUnresolved(finalUserIp, 0); + } + + @Override + public HostPort getServerAuthority() { + return new HostPort("0.0.0.0", 0); + } + + @Override + public SocketAddress getLocalSocketAddress() { + return InetSocketAddress.createUnresolved("0.0.0.0", 0); + } + }; + } }; } diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java index 3766b8938..40c911613 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java @@ -60,15 +60,12 @@ import com.google.common.base.Strings; import com.google.common.flogger.GoogleLogger; import java.time.Duration; -import java.util.Collections; import java.util.Enumeration; -import java.util.List; import java.util.Locale; import java.util.Objects; import java.util.stream.Stream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequestWrapper; - import org.eclipse.jetty.http.HttpField; import org.eclipse.jetty.http.HttpFields; import org.eclipse.jetty.http.HttpScheme; @@ -287,6 +284,7 @@ public JettyRequestAPIData( traceContext = TraceContextProto.getDefaultInstance(); } + String finalUserIp = userIp; this.httpServletRequest = new HttpServletRequestWrapper(httpServletRequest) { @@ -329,6 +327,41 @@ public String getScheme() { public boolean isSecure() { return isSecure; } + + @Override + public String getRemoteAddr() { + return finalUserIp; + } + + @Override + public String getServerName() { + return "0.0.0.0"; + } + + @Override + public String getRemoteHost() { + return finalUserIp; + } + + @Override + public int getRemotePort() { + return 0; + } + + @Override + public String getLocalName() { + return "0.0.0.0"; + } + + @Override + public String getLocalAddr() { + return "0.0.0.0"; + } + + @Override + public int getLocalPort() { + return 0; + } }; this.baseRequest = request; diff --git a/runtime/test/src/test/java/com/google/apphosting/runtime/jetty9/RemoteAddressTest.java b/runtime/test/src/test/java/com/google/apphosting/runtime/jetty9/RemoteAddressTest.java new file mode 100644 index 000000000..f2ade9ba8 --- /dev/null +++ b/runtime/test/src/test/java/com/google/apphosting/runtime/jetty9/RemoteAddressTest.java @@ -0,0 +1,101 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.apphosting.runtime.jetty9; + +import static org.hamcrest.CoreMatchers.containsString; +import static org.hamcrest.CoreMatchers.equalTo; +import static org.hamcrest.MatcherAssert.assertThat; + +import java.util.Arrays; +import java.util.Collection; +import org.eclipse.jetty.client.HttpClient; +import org.eclipse.jetty.client.api.ContentResponse; +import org.eclipse.jetty.http.HttpStatus; +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TemporaryFolder; +import org.junit.runner.RunWith; +import org.junit.runners.Parameterized; + +@RunWith(Parameterized.class) +public class RemoteAddressTest extends JavaRuntimeViaHttpBase { + + @Parameterized.Parameters + public static Collection data() { + return Arrays.asList( + new Object[][] { + {"jetty94", false}, + {"jetty94", true}, + {"ee8", false}, + {"ee8", true}, + {"ee10", false}, + {"ee10", true}, + }); + } + + @Rule public TemporaryFolder temp = new TemporaryFolder(); + private final HttpClient httpClient = new HttpClient(); + private final boolean httpMode; + private final String environment; + private RuntimeContext runtime; + + public RemoteAddressTest(String environment, boolean httpMode) { + this.environment = environment; + this.httpMode = httpMode; + System.setProperty("appengine.use.HttpConnector", Boolean.toString(httpMode)); + } + + @Before + public void before() throws Exception { + String app = "com/google/apphosting/runtime/jetty9/remoteaddrapp/" + environment; + copyAppToDir(app, temp.getRoot().toPath()); + httpClient.start(); + runtime = runtimeContext(); + System.err.println("==== Using Environment: " + environment + " " + httpMode + " ===="); + } + + @After + public void after() throws Exception { + httpClient.stop(); + runtime.close(); + } + + @Test + public void test() throws Exception { + String url = runtime.jettyUrl("/"); + ContentResponse response = httpClient.newRequest(url) + .header("X-AppEngine-User-IP", "203.0.113.1") + .send(); + + assertThat(response.getStatus(), equalTo(HttpStatus.OK_200)); + String contentReceived = response.getContentAsString(); + assertThat(contentReceived, containsString("getRemoteAddr: 203.0.113.1")); + assertThat(contentReceived, containsString("getLocalAddr: 0.0.0.0")); + assertThat(contentReceived, containsString("getServerPort: " + runtime.getPort())); + assertThat(contentReceived, containsString("getRemotePort: 0")); + assertThat(contentReceived, containsString("getLocalPort: 0")); + assertThat(contentReceived, containsString("getServerName: 0.0.0.0")); + } + + private RuntimeContext runtimeContext() throws Exception { + RuntimeContext.Config config = + RuntimeContext.Config.builder().setApplicationPath(temp.getRoot().toString()).build(); + return RuntimeContext.create(config); + } +} diff --git a/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE10EchoServlet.java b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE10EchoServlet.java index 9e8385011..b05ba44a7 100644 --- a/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE10EchoServlet.java +++ b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE10EchoServlet.java @@ -24,7 +24,6 @@ import java.util.Enumeration; import org.eclipse.jetty.util.IO; -/** Servlet that prints all the system properties. */ public class EE10EchoServlet extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { diff --git a/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE8EchoServlet.java b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE8EchoServlet.java index e9a68ac83..4133199db 100644 --- a/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE8EchoServlet.java +++ b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/gzipapp/EE8EchoServlet.java @@ -24,7 +24,6 @@ import javax.servlet.http.HttpServletResponse; import org.eclipse.jetty.util.IO; -/** Servlet that prints all the system properties. */ public class EE8EchoServlet extends HttpServlet { @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { diff --git a/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE10RemoteAddrServlet.java b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE10RemoteAddrServlet.java new file mode 100644 index 000000000..50f772aaa --- /dev/null +++ b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE10RemoteAddrServlet.java @@ -0,0 +1,37 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.apphosting.runtime.jetty9.remoteaddrapp; + +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.io.PrintWriter; + +public class EE10RemoteAddrServlet extends HttpServlet { + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { + resp.setContentType("text/plain"); + PrintWriter writer = resp.getWriter(); + writer.println("getRemoteAddr: " + req.getRemoteAddr()); + writer.println("getLocalAddr: " + req.getLocalAddr()); + writer.println("getServerPort: " + req.getServerPort()); + writer.println("getRemotePort: " + req.getRemotePort()); + writer.println("getLocalPort: " + req.getLocalPort()); + writer.println("getServerName: " + req.getServerName()); + } +} diff --git a/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE8RemoteAddrServlet.java b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE8RemoteAddrServlet.java new file mode 100644 index 000000000..cb2338b57 --- /dev/null +++ b/runtime/testapps/src/main/java/com/google/apphosting/runtime/jetty9/remoteaddrapp/EE8RemoteAddrServlet.java @@ -0,0 +1,37 @@ +/* + * Copyright 2021 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.apphosting.runtime.jetty9.remoteaddrapp; + +import java.io.IOException; +import java.io.PrintWriter; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; + +public class EE8RemoteAddrServlet extends HttpServlet { + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException { + resp.setContentType("text/plain"); + PrintWriter writer = resp.getWriter(); + writer.println("getRemoteAddr: " + req.getRemoteAddr()); + writer.println("getLocalAddr: " + req.getLocalAddr()); + writer.println("getServerPort: " + req.getServerPort()); + writer.println("getRemotePort: " + req.getRemotePort()); + writer.println("getLocalPort: " + req.getLocalPort()); + writer.println("getServerName: " + req.getServerName()); + } +} diff --git a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/gzipapp/jetty94/WEB-INF/appengine-web.xml b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/gzipapp/jetty94/WEB-INF/appengine-web.xml index d2766777d..add8402f3 100644 --- a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/gzipapp/jetty94/WEB-INF/appengine-web.xml +++ b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/gzipapp/jetty94/WEB-INF/appengine-web.xml @@ -20,6 +20,6 @@ gzip true - + diff --git a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/appengine-web.xml b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/appengine-web.xml new file mode 100644 index 000000000..c5d682552 --- /dev/null +++ b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/appengine-web.xml @@ -0,0 +1,25 @@ + + + + + java21 + remoteaddr + + + + + diff --git a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/web.xml b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/web.xml new file mode 100644 index 000000000..6641d824f --- /dev/null +++ b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee10/WEB-INF/web.xml @@ -0,0 +1,32 @@ + + + + + + Main + com.google.apphosting.runtime.jetty9.remoteaddrapp.EE10RemoteAddrServlet + + + Main + /* + + diff --git a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/appengine-web.xml b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/appengine-web.xml new file mode 100644 index 000000000..ff4b9298a --- /dev/null +++ b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/appengine-web.xml @@ -0,0 +1,25 @@ + + + + + java21 + remoteaddr + + + + + diff --git a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/web.xml b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/web.xml new file mode 100644 index 000000000..5c2bf206f --- /dev/null +++ b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/ee8/WEB-INF/web.xml @@ -0,0 +1,32 @@ + + + + + + Main + com.google.apphosting.runtime.jetty9.remoteaddrapp.EE8RemoteAddrServlet + + + Main + /* + + diff --git a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/appengine-web.xml b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/appengine-web.xml new file mode 100644 index 000000000..3643f8d09 --- /dev/null +++ b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/appengine-web.xml @@ -0,0 +1,26 @@ + + + + + java8 + remoteaddr + true + + + + + diff --git a/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/web.xml b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/web.xml new file mode 100644 index 000000000..5c2bf206f --- /dev/null +++ b/runtime/testapps/src/main/resources/com/google/apphosting/runtime/jetty9/remoteaddrapp/jetty94/WEB-INF/web.xml @@ -0,0 +1,32 @@ + + + + + + Main + com.google.apphosting.runtime.jetty9.remoteaddrapp.EE8RemoteAddrServlet + + + Main + /* + + From a9e0ea529ff0983ad7171005df4da2374e149ce9 Mon Sep 17 00:00:00 2001 From: Lachlan Roberts Date: Tue, 19 Nov 2024 11:33:20 +1100 Subject: [PATCH 2/2] assign a static field for "0.0.0.0" string Signed-off-by: Lachlan Roberts --- .../com/google/apphosting/runtime/AppEngineConstants.java | 2 ++ .../apphosting/runtime/jetty/http/JettyRequestAPIData.java | 5 +++-- .../apphosting/runtime/jetty9/JettyRequestAPIData.java | 7 ++++--- .../com/google/apphosting/runtime/jetty9/RpcEndPoint.java | 4 +++- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java index 164ada8a2..20758ff75 100644 --- a/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java +++ b/runtime/impl/src/main/java/com/google/apphosting/runtime/AppEngineConstants.java @@ -109,6 +109,8 @@ public final class AppEngineConstants { // () public static final String WARMUP_IP = "0.1.0.3"; + public static final String UNSPECIFIED_IP = "0.0.0.0"; + public static final String DEFAULT_SECRET_KEY = "secretkey"; public static final String ENVIRONMENT_ATTR = "appengine.environment"; diff --git a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java index c8375394d..627b35ebe 100644 --- a/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java +++ b/runtime/runtime_impl_jetty12/src/main/java/com/google/apphosting/runtime/jetty/http/JettyRequestAPIData.java @@ -23,6 +23,7 @@ import static com.google.apphosting.runtime.AppEngineConstants.IS_TRUSTED; import static com.google.apphosting.runtime.AppEngineConstants.PRIVATE_APPENGINE_HEADERS; import static com.google.apphosting.runtime.AppEngineConstants.SKIP_ADMIN_CHECK_ATTR; +import static com.google.apphosting.runtime.AppEngineConstants.UNSPECIFIED_IP; import static com.google.apphosting.runtime.AppEngineConstants.WARMUP_IP; import static com.google.apphosting.runtime.AppEngineConstants.WARMUP_REQUEST_URL; import static com.google.apphosting.runtime.AppEngineConstants.X_APPENGINE_API_TICKET; @@ -307,12 +308,12 @@ public SocketAddress getRemoteSocketAddress() { @Override public HostPort getServerAuthority() { - return new HostPort("0.0.0.0", 0); + return new HostPort(UNSPECIFIED_IP, 0); } @Override public SocketAddress getLocalSocketAddress() { - return InetSocketAddress.createUnresolved("0.0.0.0", 0); + return InetSocketAddress.createUnresolved(UNSPECIFIED_IP, 0); } }; } diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java index 40c911613..91696f417 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/JettyRequestAPIData.java @@ -23,6 +23,7 @@ import static com.google.apphosting.runtime.AppEngineConstants.IS_TRUSTED; import static com.google.apphosting.runtime.AppEngineConstants.PRIVATE_APPENGINE_HEADERS; import static com.google.apphosting.runtime.AppEngineConstants.SKIP_ADMIN_CHECK_ATTR; +import static com.google.apphosting.runtime.AppEngineConstants.UNSPECIFIED_IP; import static com.google.apphosting.runtime.AppEngineConstants.WARMUP_IP; import static com.google.apphosting.runtime.AppEngineConstants.WARMUP_REQUEST_URL; import static com.google.apphosting.runtime.AppEngineConstants.X_APPENGINE_API_TICKET; @@ -335,7 +336,7 @@ public String getRemoteAddr() { @Override public String getServerName() { - return "0.0.0.0"; + return UNSPECIFIED_IP; } @Override @@ -350,12 +351,12 @@ public int getRemotePort() { @Override public String getLocalName() { - return "0.0.0.0"; + return UNSPECIFIED_IP; } @Override public String getLocalAddr() { - return "0.0.0.0"; + return UNSPECIFIED_IP; } @Override diff --git a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcEndPoint.java b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcEndPoint.java index 15b38ba9b..436b2665d 100644 --- a/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcEndPoint.java +++ b/runtime/runtime_impl_jetty9/src/main/java/com/google/apphosting/runtime/jetty9/RpcEndPoint.java @@ -16,6 +16,8 @@ package com.google.apphosting.runtime.jetty9; +import static com.google.apphosting.runtime.AppEngineConstants.UNSPECIFIED_IP; + import com.google.apphosting.base.protos.RuntimePb.UPRequest; import com.google.apphosting.base.protos.RuntimePb.UPResponse; import com.google.apphosting.runtime.MutableUpResponse; @@ -55,7 +57,7 @@ public MutableUpResponse getUpResponse() { @Override public InetSocketAddress getLocalAddress() { - return InetSocketAddress.createUnresolved("0.0.0.0", 0); + return InetSocketAddress.createUnresolved(UNSPECIFIED_IP, 0); } @Override