Change calls from Addresses.getIP() to Addresses.getIPOnly() for peer IPs

getIPOnly() is more efficient for pure IP addresses (no hostnames)
This commit is contained in:
zzz
2022-12-20 08:51:29 -05:00
parent fd2af4d89c
commit 903477e905
4 changed files with 7 additions and 7 deletions

View File

@@ -1258,7 +1258,7 @@ class NetDbRenderer {
private static String getAltIPv6(String ip) {
if (ip.contains("::")) {
// convert to expanded
byte[] bip = Addresses.getIP(ip);
byte[] bip = Addresses.getIPOnly(ip);
if (bip != null)
return Addresses.toString(bip);
} else if (ip.contains(":0:")) {

View File

@@ -666,7 +666,7 @@ public class Blocklist {
* @param ip IPv4 or IPv6
*/
public void add(String ip) {
byte[] pib = Addresses.getIP(ip);
byte[] pib = Addresses.getIPOnly(ip);
if (pib == null) return;
add(pib, null);
}
@@ -681,7 +681,7 @@ public class Blocklist {
* @since 0.9.57
*/
public void add(String ip, String source) {
byte[] pib = Addresses.getIP(ip);
byte[] pib = Addresses.getIPOnly(ip);
if (pib == null) return;
add(pib, source);
}
@@ -876,7 +876,7 @@ public class Blocklist {
* @param ip IPv4 or IPv6
*/
public boolean isBlocklisted(String ip) {
byte[] pib = Addresses.getIP(ip);
byte[] pib = Addresses.getIPOnly(ip);
if (pib == null) return false;
return isBlocklisted(pib);
}

View File

@@ -559,7 +559,7 @@ public class Analysis extends JobImpl implements RouterApp {
String last = _context.getProperty("i2np.lastIP");
if (last == null)
return;
ourIP = Addresses.getIP(last);
ourIP = Addresses.getIPOnly(last);
if (ourIP == null)
return;
}

View File

@@ -770,7 +770,7 @@ public class GeoIP {
* @param ip IPv4 or IPv6
*/
public void add(String ip) {
byte[] pib = Addresses.getIP(ip);
byte[] pib = Addresses.getIPOnly(ip);
if (pib == null) return;
add(pib);
}
@@ -812,7 +812,7 @@ public class GeoIP {
* @return lower-case code, generally two letters, or null.
*/
public String get(String ip) {
byte[] pib = Addresses.getIP(ip);
byte[] pib = Addresses.getIPOnly(ip);
if (pib == null) return null;
return get(pib);
}