mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 07:10:53 +03:00
Merge pull request #141 from ziuchkovski/add-proxy-support
Add proxy support for SocketClient/SSHClient
This commit is contained in:
@@ -21,6 +21,7 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy;
|
||||
import java.net.Socket;
|
||||
|
||||
public abstract class SocketClient {
|
||||
@@ -51,12 +52,25 @@ public abstract class SocketClient {
|
||||
onConnect();
|
||||
}
|
||||
|
||||
public void connect(InetAddress host, int port, Proxy proxy)
|
||||
throws IOException {
|
||||
socket = new Socket(proxy);
|
||||
socket.connect(new InetSocketAddress(host, port), connectTimeout);
|
||||
onConnect();
|
||||
}
|
||||
|
||||
public void connect(String hostname, int port)
|
||||
throws IOException {
|
||||
this.hostname = hostname;
|
||||
connect(InetAddress.getByName(hostname), port);
|
||||
}
|
||||
|
||||
public void connect(String hostname, int port, Proxy proxy)
|
||||
throws IOException {
|
||||
this.hostname = hostname;
|
||||
connect(InetAddress.getByName(hostname), port, proxy);
|
||||
}
|
||||
|
||||
public void connect(InetAddress host, int port,
|
||||
InetAddress localAddr, int localPort)
|
||||
throws IOException {
|
||||
@@ -83,6 +97,16 @@ public abstract class SocketClient {
|
||||
connect(hostname, defaultPort);
|
||||
}
|
||||
|
||||
public void connect(InetAddress host, Proxy proxy)
|
||||
throws IOException {
|
||||
connect(host, defaultPort, proxy);
|
||||
}
|
||||
|
||||
public void connect(String hostname, Proxy proxy)
|
||||
throws IOException {
|
||||
connect(hostname, defaultPort, proxy);
|
||||
}
|
||||
|
||||
public void disconnect()
|
||||
throws IOException {
|
||||
if (socket != null) {
|
||||
@@ -170,4 +194,4 @@ public abstract class SocketClient {
|
||||
output = socket.getOutputStream();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user