forked from I2P_Developers/i2p.i2p
Util: Speed up IP address validation by using Apache's implementation (ticket #1198)
This commit is contained in:
@ -15,6 +15,8 @@ import java.util.Set;
|
||||
import java.util.SortedSet;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
|
||||
import net.i2p.I2PAppContext;
|
||||
|
||||
/**
|
||||
@ -260,12 +262,9 @@ public abstract class Addresses {
|
||||
}
|
||||
if (rv == null) {
|
||||
try {
|
||||
boolean isIPv4 = host.replaceAll("[0-9\\.]", "").length() == 0;
|
||||
if (isIPv4 && host.replaceAll("[0-9]", "").length() != 3)
|
||||
return null;
|
||||
rv = InetAddress.getByName(host).getAddress();
|
||||
if (isIPv4 ||
|
||||
host.replaceAll("[0-9a-fA-F:]", "").length() == 0) {
|
||||
if (InetAddressUtils.isIPv4Address(host) ||
|
||||
InetAddressUtils.isIPv6Address(host)) {
|
||||
synchronized (_IPAddress) {
|
||||
_IPAddress.put(host, rv);
|
||||
}
|
||||
|
@ -1,3 +1,7 @@
|
||||
2015-09-27 dg
|
||||
* Router: Fix soft restarts for 'massive' clock jumps (over +150s or -61s) and recover from standby
|
||||
and hibernate (ticket #1014).
|
||||
|
||||
2015-09-27 zzz
|
||||
* Console:
|
||||
- Export SSL cert on creation
|
||||
@ -9,8 +13,7 @@
|
||||
* Tunnels: Use max of 2 not-failing peers in an exploratory tunnel,
|
||||
use high cap for the rest; change outbound exploratory
|
||||
default length from 2 + 0-1 to 3+0.
|
||||
* Router: Fix soft restarts for 'massive' clock jumps (over +150s or -61s) and recover from standby
|
||||
and hibernate (ticket #1014).
|
||||
* Util: Speed up IP address validation by using Apache's implementation (ticket #1198)
|
||||
|
||||
2015-09-25 dg
|
||||
* Rename _() for translation to _t() for Java 9 compatibility (ticket #1456)
|
||||
|
@ -17,6 +17,8 @@ import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
|
||||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
|
||||
import net.i2p.data.DataFormatException;
|
||||
import net.i2p.data.DataHelper;
|
||||
import net.i2p.data.DataStructureImpl;
|
||||
@ -219,8 +221,8 @@ public class RouterAddress extends DataStructureImpl {
|
||||
if (host != null) {
|
||||
rv = Addresses.getIP(host);
|
||||
if (rv != null &&
|
||||
(host.replaceAll("[0-9\\.]", "").length() == 0 ||
|
||||
host.replaceAll("[0-9a-fA-F:]", "").length() == 0)) {
|
||||
(InetAddressUtils.isIPv4Address(host) ||
|
||||
InetAddressUtils.isIPv6Address(host))) {
|
||||
_ip = rv;
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,7 @@ public class RouterVersion {
|
||||
/** deprecated */
|
||||
public final static String ID = "Monotone";
|
||||
public final static String VERSION = CoreVersion.VERSION;
|
||||
public final static long BUILD = 11;
|
||||
public final static long BUILD = 12;
|
||||
|
||||
/** for example "-test" */
|
||||
public final static String EXTRA = "";
|
||||
|
@ -4,6 +4,8 @@ import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.http.conn.util.InetAddressUtils;
|
||||
|
||||
import net.i2p.data.Base64;
|
||||
import net.i2p.data.router.RouterAddress;
|
||||
import net.i2p.data.SessionKey;
|
||||
@ -262,12 +264,9 @@ class UDPAddress {
|
||||
}
|
||||
if (rv == null) {
|
||||
try {
|
||||
boolean isIPv4 = host.replaceAll("[0-9\\.]", "").length() == 0;
|
||||
if (isIPv4 && host.replaceAll("[0-9]", "").length() != 3)
|
||||
return null;
|
||||
rv = InetAddress.getByName(host);
|
||||
if (isIPv4 ||
|
||||
host.replaceAll("[0-9a-fA-F:]", "").length() == 0) {
|
||||
if (InetAddressUtils.isIPv4Address(host) ||
|
||||
InetAddressUtils.isIPv6Address(host)) {
|
||||
synchronized (_inetAddressCache) {
|
||||
_inetAddressCache.put(host, rv);
|
||||
}
|
||||
|
Reference in New Issue
Block a user