mirror of
https://github.com/bisq-network/bisq.git
synced 2025-02-28 17:15:14 +01:00
Merge pull request #7310 from alvasw/NodeAddress_Fix_broken_IPV6_parsing
NodeAddress: Fix broken IPV6 parsing
This commit is contained in:
commit
ab9385db8f
1 changed files with 13 additions and 4 deletions
|
@ -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]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue