Skip to content

Commit ee63ba8

Browse files
committed
Fixed boundary cases
Fixed weird IP string cases
1 parent 9aee502 commit ee63ba8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

com/ip2proxy/IP2Proxy.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ public class IP2Proxy {
2020
private static final Pattern Pattern4 = Pattern.compile("^(.*:)(([0-9]+\\.){3}[0-9]+)$");
2121
private static final Pattern Pattern5 = Pattern.compile("^.*((:[0-9A-F]{1,4}){2})$");
2222
private static final Pattern Pattern6 = Pattern.compile("^[0:]+((:[0-9A-F]{1,4}){1,2})$", Pattern.CASE_INSENSITIVE);
23+
private static final Pattern Pattern7 = Pattern.compile("^([0-9]+\\.){1,2}[0-9]+$");
2324
private static final BigInteger MAX_IPV4_RANGE = new BigInteger("4294967295");
2425
private static final BigInteger MAX_IPV6_RANGE = new BigInteger("340282366920938463463374607431768211455");
2526
private static final String MSG_NOT_SUPPORTED = "NOT SUPPORTED";
@@ -86,7 +87,7 @@ private enum Modes {
8687
private boolean ISP_ENABLED;
8788
private boolean PROXYTYPE_ENABLED;
8889

89-
private static final String _ModuleVersion = "1.0.0";
90+
private static final String _ModuleVersion = "1.0.1";
9091

9192
public IP2Proxy() {
9293

@@ -392,7 +393,6 @@ public ProxyResult ProxyQuery(String IPAddress) throws IOException {
392393
}
393394

394395
public ProxyResult ProxyQuery(String IPAddress, Modes Mode) throws IOException {
395-
IPAddress = IPAddress.trim();
396396
ProxyResult Result = new ProxyResult();
397397
RandomAccessFile RF = null;
398398
MappedByteBuffer Buf = null;
@@ -955,7 +955,7 @@ private BigInteger[] IP2No(String IP) throws UnknownHostException {
955955
A1 = new BigInteger("4");
956956
A2 = new BigInteger(String.valueOf(IPv4No(IP)));
957957
}
958-
else if (Pattern2.matcher(IP).matches() || Pattern3.matcher(IP).matches()) {
958+
else if (Pattern2.matcher(IP).matches() || Pattern3.matcher(IP).matches() || Pattern7.matcher(IP).matches()) {
959959
throw new UnknownHostException();
960960
}
961961
else {

0 commit comments

Comments
 (0)