Issue #1503 Optionally strip IPv6. Default true
This commit is contained in:
parent
829815be5e
commit
380b7d21e9
|
@ -72,7 +72,7 @@ public class ProxyConfigurationTest
|
|||
proxy.getExcludedAddresses().add("[1::2:3:4]:5");
|
||||
|
||||
Assert.assertFalse(proxy.matches(new Origin("http", "any", 0)));
|
||||
Assert.assertTrue(proxy.matches(new Origin("http", "[1::2:3:4]", 0)));
|
||||
Assert.assertFalse(proxy.matches(new Origin("http", "[1::2:3:4]", 5)));
|
||||
Assert.assertTrue(proxy.matches(new Origin("http", "1::2:3:4", 0)));
|
||||
Assert.assertFalse(proxy.matches(new Origin("http", "1::2:3:4", 5)));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1782,7 +1782,7 @@ public class HttpParserTest
|
|||
HttpParser.RequestHandler handler = new Handler();
|
||||
HttpParser parser = new HttpParser(handler);
|
||||
parser.parseNext(buffer);
|
||||
Assert.assertEquals("[::1]", _host);
|
||||
Assert.assertEquals("::1", _host);
|
||||
Assert.assertEquals(0, _port);
|
||||
}
|
||||
|
||||
|
@ -1863,7 +1863,7 @@ public class HttpParserTest
|
|||
HttpParser.RequestHandler handler = new Handler();
|
||||
HttpParser parser = new HttpParser(handler);
|
||||
parser.parseNext(buffer);
|
||||
Assert.assertEquals("[::1]", _host);
|
||||
Assert.assertEquals("::1", _host);
|
||||
Assert.assertEquals(8888, _port);
|
||||
}
|
||||
|
||||
|
|
|
@ -90,6 +90,7 @@ public class ForwardedRequestCustomizer implements Customizer
|
|||
* not support any {@code X-Forwarded-} headers. This convenience method
|
||||
* clears all the non RFC headers if passed true and sets them to
|
||||
* the default values (if not already set) if passed false.
|
||||
* @param rfc7239only Configure to support only RFC7239
|
||||
*/
|
||||
public void setForwardedOnly(boolean rfc7239only)
|
||||
{
|
||||
|
|
|
@ -66,7 +66,7 @@ public class CheckReverseProxyHeadersTest
|
|||
@Override
|
||||
public void validate(HttpServletRequest request)
|
||||
{
|
||||
assertEquals("[::1]", request.getServerName());
|
||||
assertEquals("::1", request.getServerName());
|
||||
assertEquals(80, request.getServerPort());
|
||||
assertEquals("10.20.30.40", request.getRemoteAddr());
|
||||
assertEquals("10.20.30.40", request.getRemoteHost());
|
||||
|
@ -84,7 +84,7 @@ public class CheckReverseProxyHeadersTest
|
|||
@Override
|
||||
public void validate(HttpServletRequest request)
|
||||
{
|
||||
assertEquals("[::1]", request.getServerName());
|
||||
assertEquals("::1", request.getServerName());
|
||||
assertEquals(8888, request.getServerPort());
|
||||
assertEquals("10.20.30.40", request.getRemoteAddr());
|
||||
assertEquals("10.20.30.40", request.getRemoteHost());
|
||||
|
|
|
@ -38,7 +38,6 @@ import org.eclipse.jetty.server.handler.AbstractHandler;
|
|||
import org.eclipse.jetty.util.IO;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.After;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
|
@ -112,7 +111,7 @@ public class ForwardedRequestCustomizerTest
|
|||
assertEquals("http",_results.poll());
|
||||
assertEquals("myhost",_results.poll());
|
||||
assertEquals("80",_results.poll());
|
||||
assertEquals("[2001:db8:cafe::17]",_results.poll());
|
||||
assertEquals("2001:db8:cafe::17",_results.poll());
|
||||
assertEquals("4711",_results.poll());
|
||||
}
|
||||
|
||||
|
@ -184,6 +183,22 @@ public class ForwardedRequestCustomizerTest
|
|||
assertEquals("192.0.2.43",_results.poll());
|
||||
assertEquals("0",_results.poll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRFC7239_IPv6() throws Exception
|
||||
{
|
||||
_connector.getResponse(
|
||||
"GET / HTTP/1.1\n"+
|
||||
"Host: myhost\n"+
|
||||
"Forwarded: for=\"[2001:db8:cafe::1]\";by=\"[2001:db8:cafe::2]\";host=\"[2001:db8:cafe::3]:8888\"\n"+
|
||||
"\n");
|
||||
|
||||
assertEquals("http",_results.poll());
|
||||
assertEquals("2001:db8:cafe::3",_results.poll());
|
||||
assertEquals("8888",_results.poll());
|
||||
assertEquals("2001:db8:cafe::1",_results.poll());
|
||||
assertEquals("0",_results.poll());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testProto() throws Exception
|
||||
|
|
|
@ -628,7 +628,7 @@ public class RequestTest
|
|||
assertThat(response, containsString("200 OK"));
|
||||
assertEquals("http://[::1]/",results.get(i++));
|
||||
assertEquals("0.0.0.0",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("80",results.get(i++));
|
||||
|
||||
|
||||
|
@ -642,7 +642,7 @@ public class RequestTest
|
|||
assertThat(response, containsString("200 OK"));
|
||||
assertEquals("http://[::1]:8888/",results.get(i++));
|
||||
assertEquals("0.0.0.0",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("8888",results.get(i++));
|
||||
|
||||
|
||||
|
@ -658,7 +658,7 @@ public class RequestTest
|
|||
assertThat(response, containsString("200 OK"));
|
||||
assertEquals("https://[::1]/",results.get(i++));
|
||||
assertEquals("remote",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("443",results.get(i++));
|
||||
|
||||
|
||||
|
@ -674,7 +674,7 @@ public class RequestTest
|
|||
assertThat(response, containsString("200 OK"));
|
||||
assertEquals("https://[::1]:8888/",results.get(i++));
|
||||
assertEquals("remote",results.get(i++));
|
||||
assertEquals("[::1]",results.get(i++));
|
||||
assertEquals("::1",results.get(i++));
|
||||
assertEquals("8888",results.get(i++));
|
||||
}
|
||||
|
||||
|
|
|
@ -43,8 +43,8 @@ public class HostPortTest
|
|||
{"host:80","host","80"},
|
||||
{"10.10.10.1","10.10.10.1",null},
|
||||
{"10.10.10.1:80","10.10.10.1","80"},
|
||||
{"[0::0::0::1]","[0::0::0::1]",null},
|
||||
{"[0::0::0::1]:80","[0::0::0::1]","80"},
|
||||
{"[0::0::0::1]","0::0::0::1",null},
|
||||
{"[0::0::0::1]:80","0::0::0::1","80"},
|
||||
|
||||
{null,null,null},
|
||||
{"host:",null,null},
|
||||
|
|
Loading…
Reference in New Issue