Class LocalPortForwarder
- java.lang.Object
-
- net.schmizz.sshj.connection.channel.direct.LocalPortForwarder
-
public class LocalPortForwarder extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
LocalPortForwarder.ForwardedChannel
-
Field Summary
Fields Modifier and Type Field Description private Connection
conn
private org.slf4j.Logger
log
private LoggerFactory
loggerFactory
private Parameters
parameters
private java.lang.Thread
runningThread
private java.net.ServerSocket
serverSocket
-
Constructor Summary
Constructors Constructor Description LocalPortForwarder(Connection conn, Parameters parameters, java.net.ServerSocket serverSocket, LoggerFactory loggerFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the ServerSocket that's listening for connections to forward.boolean
isRunning()
Returns whether this listener is running (ie.void
listen()
Start listening for incoming connections and forward to remote host as a channel.void
listen(java.lang.Thread runningThread)
Start listening for incoming connections and forward to remote host as a channel and ensure that the thread is registered.private void
startChannel(java.net.Socket socket)
-
-
-
Field Detail
-
loggerFactory
private final LoggerFactory loggerFactory
-
log
private final org.slf4j.Logger log
-
conn
private final Connection conn
-
parameters
private final Parameters parameters
-
serverSocket
private final java.net.ServerSocket serverSocket
-
runningThread
private java.lang.Thread runningThread
-
-
Constructor Detail
-
LocalPortForwarder
public LocalPortForwarder(Connection conn, Parameters parameters, java.net.ServerSocket serverSocket, LoggerFactory loggerFactory)
-
-
Method Detail
-
startChannel
private void startChannel(java.net.Socket socket) throws java.io.IOException
- Throws:
java.io.IOException
-
listen
public void listen() throws java.io.IOException
Start listening for incoming connections and forward to remote host as a channel.- Throws:
java.io.IOException
-
isRunning
public boolean isRunning()
Returns whether this listener is running (ie. whether a thread is attached to it).- Returns:
-
listen
public void listen(java.lang.Thread runningThread) throws java.io.IOException
Start listening for incoming connections and forward to remote host as a channel and ensure that the thread is registered. This is useful if for instanceis called from another thread
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
Close the ServerSocket that's listening for connections to forward.- Throws:
java.io.IOException
-
-