Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 25 additions & 1 deletion src/main/java/net/schmizz/sshj/SocketClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.OutputStream;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.Socket;

public abstract class SocketClient {
Expand Down Expand Up @@ -51,12 +52,25 @@ public void connect(InetAddress host, int port)
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 {
Expand All @@ -83,6 +97,16 @@ public void connect(String hostname)
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) {
Expand Down Expand Up @@ -170,4 +194,4 @@ void onConnect()
output = socket.getOutputStream();
}

}
}