我有一个使用 Ganymed 的 LocalPortForwarder 类创建的 ssh 隧道。它工作正常。问题是如何(以 Java 编程方式)检查隧道是否仍处于打开状态且处于活动状态?
作为参考,这里是创建隧道的代码片段(为简洁起见,删除了错误检查):
Connection conn = new Connection(remoteHostName);
conn.connect();
boolean isAuthenticated = conn.authenticateWithPassword(username, password);
LocalPortForwarder lpf1
= conn.createLocalPortForwarder(newPort,
remoteHostName,
Integer.parseInt(remoteHostPort));