chore: handle IPv6 addresses correctly in RDP connection string

This commit is contained in:
hstyi
2025-12-22 09:13:23 +08:00
committed by GitHub
parent dad4d26fd8
commit 3ece32e427

View File

@@ -10,6 +10,8 @@ import kotlinx.coroutines.launch
import org.apache.commons.io.FileUtils
import org.apache.commons.io.IOUtils
import org.apache.commons.lang3.StringUtils
import org.apache.commons.lang3.Strings
import org.apache.commons.lang3.SystemUtils
import java.awt.datatransfer.DataFlavor
import java.awt.datatransfer.StringSelection
import java.net.URI
@@ -64,7 +66,15 @@ internal class RDPProtocolProvider private constructor() : GenericProtocolProvid
}
val sb = StringBuilder()
sb.append("full address:s:").append(host.host).append(':').append(host.port).appendLine()
sb.append("full address:s:")
if (SystemUtils.IS_OS_WINDOWS && Strings.CI.contains(host.host, ":")) {
var newHost = Strings.CI.removeStart(host.host, "[")
newHost = Strings.CI.removeEnd(newHost, "]")
sb.append('[').append(newHost).append(']')
} else {
sb.append(host.host)
}
sb.append(':').append(host.port).appendLine()
sb.append("username:s:").append(host.username).appendLine()
val desktop = host.options.extras["desktop"]
if (desktop.isNullOrBlank().not()) {