mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-07 15:50:57 +03:00
Add support for tunneling via channels (#511)
This commit is contained in:
committed by
Jeroen van Erp
parent
633b42fec8
commit
fdf08ef3c9
@@ -17,6 +17,7 @@ package net.schmizz.sshj;
|
|||||||
|
|
||||||
import com.hierynomus.sshj.backport.JavaVersion;
|
import com.hierynomus.sshj.backport.JavaVersion;
|
||||||
import com.hierynomus.sshj.backport.Jdk7HttpProxySocket;
|
import com.hierynomus.sshj.backport.Jdk7HttpProxySocket;
|
||||||
|
import net.schmizz.sshj.connection.channel.Channel;
|
||||||
import net.schmizz.sshj.connection.channel.direct.DirectConnection;
|
import net.schmizz.sshj.connection.channel.direct.DirectConnection;
|
||||||
|
|
||||||
import javax.net.SocketFactory;
|
import javax.net.SocketFactory;
|
||||||
@@ -148,16 +149,20 @@ public abstract class SocketClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Connect to a remote address via a direct TCP/IP connection from the server. */
|
public void connectVia(Channel channel, String hostname, int port) throws IOException {
|
||||||
public void connectVia(DirectConnection directConnection) throws IOException {
|
this.hostname = hostname;
|
||||||
this.hostname = directConnection.getRemoteHost();
|
this.port = port;
|
||||||
this.port = directConnection.getRemotePort();
|
this.input = channel.getInputStream();
|
||||||
this.input = directConnection.getInputStream();
|
this.output = channel.getOutputStream();
|
||||||
this.output = directConnection.getOutputStream();
|
|
||||||
this.tunneled = true;
|
this.tunneled = true;
|
||||||
onConnect();
|
onConnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Connect to a remote address via a direct TCP/IP connection from the server. */
|
||||||
|
public void connectVia(DirectConnection directConnection) throws IOException {
|
||||||
|
connectVia(directConnection, directConnection.getRemoteHost(), directConnection.getRemotePort());
|
||||||
|
}
|
||||||
|
|
||||||
public void connect(InetAddress host) throws IOException {
|
public void connect(InetAddress host) throws IOException {
|
||||||
connect(host, defaultPort);
|
connect(host, defaultPort);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user