mirror of
https://github.com/moonlight-stream/moonlight-android.git
synced 2026-10-20 15:27:18 +00:00
Handle escaping and unescaping IPv6 addresses in AddressTuple
This commit is contained in:
1 parent
381598c5b6
commit
ec57499e08
1 file changed
+13
-1
@@ -20,6 +20,11 @@ public class ComputerDetails {
|
||||
throw new IllegalArgumentException("Invalid port");
|
||||
}
|
||||
|
||||
// If this was an escaped IPv6 address, remove the brackets
|
||||
if (address.startsWith("[") && address.endsWith("]")) {
|
||||
address = address.substring(1, address.length() - 1);
|
||||
}
|
||||
|
||||
this.address = address;
|
||||
this.port = port;
|
||||
}
|
||||
@@ -40,7 +45,14 @@ public class ComputerDetails {
|
||||
}
|
||||
|
||||
public String toString() {
|
||||
return address + ":" + port;
|
||||
if (address.contains(":")) {
|
||||
// IPv6
|
||||
return "[" + address + "]:" + port;
|
||||
}
|
||||
else {
|
||||
// IPv4 and hostnames
|
||||
return address + ":" + port;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user