From c4ac0b16faa310d15636978c8ed7c81c4e62a537 Mon Sep 17 00:00:00 2001 From: Alva Swanson Date: Mon, 18 Nov 2024 22:18:57 +0000 Subject: [PATCH] NodeAddress: Fix broken IPV6 parsing Bisq accepts IPV6 node addresses but the NodeAddress can't parse them. --- .../main/java/bisq/network/p2p/NodeAddress.java | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/p2p/src/main/java/bisq/network/p2p/NodeAddress.java b/p2p/src/main/java/bisq/network/p2p/NodeAddress.java index d1aa456118..86d2758610 100644 --- a/p2p/src/main/java/bisq/network/p2p/NodeAddress.java +++ b/p2p/src/main/java/bisq/network/p2p/NodeAddress.java @@ -47,10 +47,19 @@ public final class NodeAddress implements PersistablePayload, NetworkPayload, Us } public NodeAddress(String fullAddress) { - final String[] split = fullAddress.split(Pattern.quote(":")); - checkArgument(split.length == 2, "fullAddress must contain ':'"); - this.hostName = split[0]; - this.port = Integer.parseInt(split[1]); + String[] split = fullAddress.split("]"); + boolean isIpV6Address = split.length == 2 && fullAddress.startsWith("["); + if (isIpV6Address) { + this.hostName = split[0].replace("[", ""); + String portString = split[1].replace(":", ""); + this.port = Integer.parseInt(portString); + } else { + split = fullAddress.split(Pattern.quote(":")); + checkArgument(split.length == 2, "fullAddress must contain ':'"); + this.hostName = split[0]; + + this.port = Integer.parseInt(split[1]); + } }