mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: SSH authentication causing IP and port changes (#610)
This commit is contained in:
@@ -265,7 +265,7 @@ object SshClients {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
if (e !is SshException || e.disconnectCode != SshConstants.SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE) throw e
|
if (e !is SshException || e.disconnectCode != SshConstants.SSH2_DISCONNECT_NO_MORE_AUTH_METHODS_AVAILABLE) throw e
|
||||||
val owner = client.properties["owner"] as Window? ?: throw e
|
val owner = client.properties["owner"] as Window? ?: throw e
|
||||||
val authentication = ask(host, owner) ?: throw e
|
val authentication = ask(host, entry, owner) ?: throw e
|
||||||
if (authentication.type == AuthenticationType.No) throw e
|
if (authentication.type == AuthenticationType.No) throw e
|
||||||
return doOpenSession(host.copy(authentication = authentication), client)
|
return doOpenSession(host.copy(authentication = authentication), client)
|
||||||
}
|
}
|
||||||
@@ -414,7 +414,7 @@ object SshClients {
|
|||||||
return sshClient
|
return sshClient
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ask(host: Host, owner: Window): Authentication? {
|
private fun ask(host: Host, entry: HostConfigEntry, owner: Window): Authentication? {
|
||||||
val ref = AtomicReference<Authentication>(null)
|
val ref = AtomicReference<Authentication>(null)
|
||||||
SwingUtilities.invokeAndWait {
|
SwingUtilities.invokeAndWait {
|
||||||
val dialog = RequestAuthenticationDialog(owner, host)
|
val dialog = RequestAuthenticationDialog(owner, host)
|
||||||
@@ -422,12 +422,18 @@ object SshClients {
|
|||||||
val authentication = dialog.getAuthentication().apply { ref.set(this) }
|
val authentication = dialog.getAuthentication().apply { ref.set(this) }
|
||||||
// save
|
// save
|
||||||
if (dialog.isRemembered()) {
|
if (dialog.isRemembered()) {
|
||||||
hostManager.addHost(
|
// fix https://github.com/TermoraDev/termora/issues/609
|
||||||
host.copy(
|
val hostId = entry.getProperty("Host", host.id)
|
||||||
authentication = authentication,
|
val h = hostManager.getHost(hostId)
|
||||||
username = dialog.getUsername(), updateDate = System.currentTimeMillis(),
|
if (h != null) {
|
||||||
|
hostManager.addHost(
|
||||||
|
h.copy(
|
||||||
|
authentication = authentication,
|
||||||
|
username = dialog.getUsername(), updateDate = System.currentTimeMillis(),
|
||||||
|
)
|
||||||
)
|
)
|
||||||
)
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ref.get()
|
return ref.get()
|
||||||
|
|||||||
Reference in New Issue
Block a user