-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
2.2.7.Final
-
None
ProxyForwardedTestCase and ProxyXForwardedTestCase has the following check:
85 @Test 86 public void testProxyPeerHandler() throws IOException, ServletException { 87 TestHttpClient client = new TestHttpClient(); 88 try { : 99 Socket socket = new Socket(); 100 socket.connect(new InetSocketAddress(DefaultServer.getHostAddress(), PORT)); 101 102 Assert.assertEquals(StatusCodes.OK, result.getStatusLine().getStatusCode()); 103 Assert.assertEquals(socket.getLocalAddress().getHostAddress(), map.get(GenericServletConstants.LOCAL_ADDR)); 104 Assert.assertEquals(socket.getLocalAddress().getHostName(), map.get(GenericServletConstants.LOCAL_NAME)); 105 Assert.assertEquals(PORT, Integer.parseInt(map.get(GenericServletConstants.LOCAL_PORT))); 106 Assert.assertEquals("192.0.2.10", map.get(GenericServletConstants.SERVER_NAME)); 107 Assert.assertEquals("8888", map.get(GenericServletConstants.SERVER_PORT)); 108 Assert.assertEquals("192.0.2.43", map.get(GenericServletConstants.REMOTE_ADDR)); 109 Assert.assertEquals("0", map.get(GenericServletConstants.REMOTE_PORT)); 110
At line 103 and 104, it checks the results with socket.getLocalAddress(). This socket.getLocalAddress() returns a client-side local address of this socket.
However, as ServletRequest.getLocalAddr(), ServletRequest.getLocalNamet() and ServletRequest.getLocalPort() are executed on the server-side, the result contains the local address of the server.
A unit test runs on the same local machine (localhost), so the above check passes luckily. But I think the test code does not check correctly.
I think Socket.getInetAddress() should be used instead of Socket.getLocalAddress().
I think DefaultServer.getDefaultServerAddress() should be used instead of Socket.getLocalAddress().
- is caused by
-
UNDERTOW-1837 ServletRequest#getLocalPort(), getLocalAddr() and getLocalName() can return wrong information when ProxyPeerAddressHandler or ForwardedHandler is enabled
- Resolved