mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
fix: tunnels causes connection failure (#279)
This commit is contained in:
@@ -26,6 +26,7 @@ import org.apache.sshd.common.channel.ChannelListener
|
|||||||
import org.apache.sshd.common.session.Session
|
import org.apache.sshd.common.session.Session
|
||||||
import org.apache.sshd.common.session.SessionListener
|
import org.apache.sshd.common.session.SessionListener
|
||||||
import org.apache.sshd.common.session.SessionListener.Event
|
import org.apache.sshd.common.session.SessionListener.Event
|
||||||
|
import org.slf4j.LoggerFactory
|
||||||
import java.nio.charset.StandardCharsets
|
import java.nio.charset.StandardCharsets
|
||||||
import java.util.*
|
import java.util.*
|
||||||
import javax.swing.JComponent
|
import javax.swing.JComponent
|
||||||
@@ -36,6 +37,8 @@ class SSHTerminalTab(windowScope: WindowScope, host: Host) :
|
|||||||
PtyHostTerminalTab(windowScope, host) {
|
PtyHostTerminalTab(windowScope, host) {
|
||||||
companion object {
|
companion object {
|
||||||
val SSHSession = DataKey(ClientSession::class)
|
val SSHSession = DataKey(ClientSession::class)
|
||||||
|
|
||||||
|
private val log = LoggerFactory.getLogger(SSHTerminalTab::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val mutex = Mutex()
|
private val mutex = Mutex()
|
||||||
@@ -191,12 +194,20 @@ class SSHTerminalTab(windowScope: WindowScope, host: Host) :
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (tunneling in host.tunnelings) {
|
for (tunneling in host.tunnelings) {
|
||||||
|
try {
|
||||||
SshClients.openTunneling(session, host, tunneling)
|
SshClients.openTunneling(session, host, tunneling)
|
||||||
|
withContext(Dispatchers.Swing) {
|
||||||
withContext(Dispatchers.Swing) {
|
terminal.write("Start [${tunneling.name}] port forwarding successfully.\r\n")
|
||||||
terminal.write("Start [${tunneling.name}] port forwarding successfully.\r\n")
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
if (log.isErrorEnabled) {
|
||||||
|
log.error("Start [${tunneling.name}] port forwarding failed: {}", e.message, e)
|
||||||
|
}
|
||||||
|
withContext(Dispatchers.Swing) {
|
||||||
|
terminal.write("Start [${tunneling.name}] port forwarding failed: ${e.message}\r\n")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user