Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.mindbright.ssh2
Class SSH2Listener

    java.lang.Object
      com.mindbright.ssh2.SSH2Listener

All Implemented Interfaces:
  java.lang.Runnable

public final class SSH2Listener
extends java.lang.Object
implements java.lang.Runnable

This class accepts connections to a single address/port pair for creating channels through port forwards. It contains a thread which basically contains an accept loop in which new connections are accepted and new channels are created along with CHANNEL_OPEN messages to peer. There is one `SSH2Listener` instance for each local forward.

See Also:
  `SSH2Connection`

Constructor Summary
`SSH2Listener(java.lang.String localAddr, int localPort, SSH2Connection connection)` Creates the remote listener for remote connections.
`SSH2Listener(java.lang.String localAddr, int localPort, java.lang.String remoteAddr, int remotePort, SSH2Connection connection, SSH2StreamFilterFactory filterFactory)` Creates a listener for filtered connections.
`SSH2Listener(java.lang.String localAddr, int localPort, java.lang.String remoteAddr, int remotePort, SSH2Connection connection, SSH2StreamFilterFactory filterFactory, int acceptTimeout)` Creates a listener for filtered connections.

Method Summary
`void` | `doConnect(java.net.Socket fwdSocket)` Handle a connect from the given socket.
`SSH2Connection` | `getConnection()`
`java.lang.String` | `getListenHost()`
`int` | `getListenPort()`
`java.lang.String` | `getRemoteHost()`
`int` | `getRemotePort()`
`void` | `run()` Run the listener and listen for connections.
`void` | `sendChannelOpen(SSH2TCPChannel channel, java.net.Socket fwdSocket)` Send a channel open for the given socket.
`void` | `setAcceptMax(int acceptMax)`
`void` | `setRetries(int numOfRetries)`
`void` | `setRetryDelay(long retryDelayTime)`
`void` | `setThreadPriority(int prio)`
`void` | `stop()` Stop the listener.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### SSH2Listener

    public SSH2Listener(java.lang.String localAddr,
                        int localPort,
                        java.lang.String remoteAddr,
                        int remotePort,
                        SSH2Connection connection,
                        SSH2StreamFilterFactory filterFactory,
                        int acceptTimeout)
                 throws java.io.IOException

  Creates a listener for filtered connections.

Parameters:
  `localAddr` - The address to open the listener to. should normally be "127.0.0.1".
  `localPort` - The local port to listen at.
  `remoteAddr` - The remote address to connect to. Note that this name is resolved on the server.
  `remotePort` - The remote port to connect to.
  `connection` - The connection to use.
  `filterFactory` - Factory which creates filter instances. There will be one filter created per connection.
  `acceptTimeout` - Timeout for accept call.

### SSH2Listener

    public SSH2Listener(java.lang.String localAddr,
                        int localPort,
                        java.lang.String remoteAddr,
                        int remotePort,
                        SSH2Connection connection,
                        SSH2StreamFilterFactory filterFactory)
                 throws java.io.IOException

  Creates a listener for filtered connections.

Parameters:
  `localAddr` - The address to open the listener to. should normally be "127.0.0.1".
  `localPort` - The local port to listen at.
  `remoteAddr` - The remote address to connect to. Note that this name is resolved on the server.
  `remotePort` - The remote port to connect to.
  `connection` - The connection to use.
  `filterFactory` - Factory which creates filter instances. There will be one filter created per connection.

### SSH2Listener

    public SSH2Listener(java.lang.String localAddr,
                        int localPort,
                        SSH2Connection connection)
                 throws java.io.IOException

  Creates the remote listener for remote connections.

Parameters:
  `localAddr` - The address to open the listener to. should normally be "127.0.0.1".
  `localPort` - The local port to listen at.
  `connection` - The connection to use.

Method Detail

### run

    public void run()

  Run the listener and listen for connections.

  Specified by:
    `run` in interface `java.lang.Runnable`

### doConnect

    public void doConnect(java.net.Socket fwdSocket)

  Handle a connect from the given socket. This is used to sneak in connections from other parts of the application.

  Parameters:
    `fwdSocket` - A connected socket.

### sendChannelOpen

    public void sendChannelOpen(SSH2TCPChannel channel,
                                java.net.Socket fwdSocket)

  Send a channel open for the given socket. This is useful when one wants to retry to open a channel when previous attempts have failed. One must call `doConnect` once first before calling this function.

  Parameters:
    `channel` - The channel to retry to open on.
    `fwdSocket` - Socket identifying the local end.

### getConnection

    public SSH2Connection getConnection()

### setAcceptMax

    public void setAcceptMax(int acceptMax)

### setRetries

    public void setRetries(int numOfRetries)

### setRetryDelay

    public void setRetryDelay(long retryDelayTime)

### setThreadPriority

    public void setThreadPriority(int prio)

### getListenPort

    public int getListenPort()

### getListenHost

    public java.lang.String getListenHost()

### getRemotePort

    public int getRemotePort()

### getRemoteHost

    public java.lang.String getRemoteHost()

### stop

    public void stop()

  Stop the listener. That is do not accept any more connections. Existing connections will not be affected.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD