From 8447086c59184a2e519ff7e4f75097fed64c1a35 Mon Sep 17 00:00:00 2001 From: zzz Date: Tue, 30 Mar 2021 07:14:35 -0400 Subject: [PATCH] Transport: Fix NTCP removing IPv4 address when SSU removes IPv6 address --- .../net/i2p/router/transport/CommSystemFacadeImpl.java | 8 +++----- .../java/src/net/i2p/router/transport/TransportUtil.java | 2 ++ 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java index 61d988db3..722df0de6 100644 --- a/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java +++ b/router/java/src/net/i2p/router/transport/CommSystemFacadeImpl.java @@ -323,21 +323,19 @@ public class CommSystemFacadeImpl extends CommSystemFacade { if (ip != null || port > 0) _manager.externalAddressReceived(Transport.AddressSource.SOURCE_SSU, ip, port); else - notifyRemoveAddress(false); + notifyRemoveAddress(udpAddr); } /** * Tell other transports our address changed * - * @param address non-null; but address's host/IP may be null + * @param address may be null; or address's host/IP may be null * @since 0.9.20 */ @Override public void notifyRemoveAddress(RouterAddress address) { // just keep this simple for now, multiple v4 or v6 addresses not yet supported - notifyRemoveAddress(address != null && - address.getIP() != null && - address.getIP().length == 16); + notifyRemoveAddress(address != null && TransportUtil.isIPv6(address)); } /** diff --git a/router/java/src/net/i2p/router/transport/TransportUtil.java b/router/java/src/net/i2p/router/transport/TransportUtil.java index e00f094f0..2e4565d20 100644 --- a/router/java/src/net/i2p/router/transport/TransportUtil.java +++ b/router/java/src/net/i2p/router/transport/TransportUtil.java @@ -124,6 +124,8 @@ public abstract class TransportUtil { /** * Addresses without a host (i.e. w/introducers) * are assumed to be IPv4 unless a '6' cap is present + * + * @param addr non-null */ public static boolean isIPv6(RouterAddress addr) { // do this the fast way, without calling getIP() to parse the host string