Skip to content

Commit

Permalink
Responses to review comments, and other bugfixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanLennox committed Jul 8, 2024
1 parent f50ff95 commit 3f6ab6e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 5 deletions.
29 changes: 26 additions & 3 deletions src/main/java/org/ice4j/TransportAddress.java
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,15 @@ private String toString(boolean redact)
if (redact)
{
hostAddress = getRedactedAddress();
if (hostAddress == null)
{
String hostName = getHostName();
if (hostName != null)
{
/* The transport address is an unresolved hostname. Redact the hostname. */
hostAddress = "xxxx.xxx";
}
}
}
else
{
Expand All @@ -170,6 +179,11 @@ private String toString(boolean redact)
hostAddress = getHostName();
}
}
if (hostAddress == null)
{
// The address has neither a hostName nor a hostAddress. Shouldn't happen, but don't NPE if it does. */
hostAddress = "null";
}

StringBuilder bldr = new StringBuilder(hostAddress);

Expand Down Expand Up @@ -204,7 +218,15 @@ public String getRedactedAddress()
{
if (AgentConfig.config.getRedactRemoteAddresses())
{
return toRedactedString(getAddress());
InetAddress addr = getAddress();
if (addr != null)
{
return toRedactedString(addr);
}
else
{
return null;
}
}
else
{
Expand Down Expand Up @@ -359,15 +381,16 @@ public static String toRedactedString(InetAddress addr)
{
return null;
}
if (addr.isLoopbackAddress())
if (addr.isAnyLocalAddress() || addr.isLoopbackAddress())
{
return addr.getHostAddress();
}
if (addr instanceof Inet6Address)
{
StringBuilder sb = new StringBuilder();
byte[] addrBytes = addr.getAddress();
if ((addrBytes[0] & 0xe0) == 0x20) {
if ((addrBytes[0] & 0xe0) == 0x20)
{
/* Globally-routable IPv6 address; the second nybble can indicate the
* RIR that allocated the address, so don't print it.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/ice4j/ice/Component.java
Original file line number Diff line number Diff line change
Expand Up @@ -603,11 +603,11 @@ public String toString()
buff.append("\ndefault remote candidate: ");
if (defaultRemoteCandidate != null)
{
buff.append(getDefaultRemoteCandidate().toRedactedString());
buff.append(defaultRemoteCandidate.toRedactedString());
}
else
{
buff.append((String)null);
buff.append("null");
}

synchronized(remoteCandidates)
Expand Down

0 comments on commit 3f6ab6e

Please sign in to comment.