src/Pure/General/ssh.scala
changeset 65009 eda9366bbfac
parent 64347 602483aa7818
child 65010 a27e9908dcf7
--- a/src/Pure/General/ssh.scala	Thu Feb 09 11:44:55 2017 +0100
+++ b/src/Pure/General/ssh.scala	Thu Feb 09 15:40:34 2017 +0100
@@ -129,6 +129,14 @@
   }
 
 
+  /* port forwarding */
+
+  sealed case class Port_Forwarding(ssh: SSH.Session, host: String, port: Int)
+  {
+    def close() { ssh.session.delPortForwardingL(host, port) }
+  }
+
+
   /* Sftp channel */
 
   type Attrs = SftpATTRS
@@ -235,6 +243,15 @@
       user_prefix + host + port_suffix + (if (session.isConnected) "" else " (disconnected)")
 
 
+    /* port forwarding */
+
+    def port_forwarding(
+        remote_port: Int, remote_host: String = "localhost",
+        local_port: Int = 0, local_host: String = "localhost"): Port_Forwarding =
+      Port_Forwarding(this, local_host,
+        session.setPortForwardingL(local_host, local_port, remote_host, remote_port))
+
+
     /* sftp channel */
 
     val sftp: ChannelSftp = session.openChannel("sftp").asInstanceOf[ChannelSftp]