forked from I2P_Developers/i2p.i2p
Util: Add methods to validate IP addresses
This commit is contained in:
@@ -10,11 +10,10 @@ import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.util.Addresses;
|
||||
import net.i2p.util.Log;
|
||||
import net.i2p.util.PortMapper;
|
||||
|
||||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
|
||||
@@ -128,7 +127,7 @@ public class HostCheckHandler extends HandlerWrapper
|
||||
if (_listenHosts.contains(host))
|
||||
return true;
|
||||
// allow all IP addresses
|
||||
if (InetAddressUtils.isIPv4Address(host) || InetAddressUtils.isIPv6Address(host))
|
||||
if (Addresses.isIPAddress(host))
|
||||
return true;
|
||||
//System.out.println(host + " not found in " + s);
|
||||
return false;
|
||||
|
||||
@@ -42,8 +42,6 @@ import net.i2p.util.SecureDirectory;
|
||||
import net.i2p.util.I2PSSLSocketFactory;
|
||||
import net.i2p.util.SystemVersion;
|
||||
|
||||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
@@ -518,9 +516,9 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
try {
|
||||
// Test before we add the connector, because Jetty 6 won't start if any of the
|
||||
// connectors are bad
|
||||
if ((!hasIPV6) && InetAddressUtils.isIPv6Address(host))
|
||||
if ((!hasIPV6) && Addresses.isIPv6Address(host))
|
||||
throw new IOException("IPv6 addresses unsupported");
|
||||
if ((!hasIPV4) && InetAddressUtils.isIPv4Address(host))
|
||||
if ((!hasIPV4) && Addresses.isIPv4Address(host))
|
||||
throw new IOException("IPv4 addresses unsupported");
|
||||
ServerSocket testSock = null;
|
||||
try {
|
||||
@@ -608,9 +606,9 @@ public class RouterConsoleRunner implements RouterApp {
|
||||
try {
|
||||
// Test before we add the connector, because Jetty 6 won't start if any of the
|
||||
// connectors are bad
|
||||
if ((!hasIPV6) && InetAddressUtils.isIPv6Address(host))
|
||||
if ((!hasIPV6) && Addresses.isIPv6Address(host))
|
||||
throw new IOException("IPv6 addresses unsupported");
|
||||
if ((!hasIPV4) && InetAddressUtils.isIPv4Address(host))
|
||||
if ((!hasIPV4) && Addresses.isIPv4Address(host))
|
||||
throw new IOException("IPv4 addresses unsupported");
|
||||
ServerSocket testSock = null;
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user