Class DefaultForwarder
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.common.util.closeable.IoBaseCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractInnerCloseable
org.apache.sshd.common.forward.DefaultForwarder
- All Implemented Interfaces:
Closeable, AutoCloseable, Channel, org.apache.sshd.common.Closeable, Forwarder, PortForwardingEventListenerManager, PortForwardingEventListenerManagerHolder, PortForwardingInformationProvider, PortForwardingManager, org.apache.sshd.common.session.SessionContextHolder, SessionHolder<Session>
public class DefaultForwarder
extends org.apache.sshd.common.util.closeable.AbstractInnerCloseable
implements Forwarder, SessionHolder<Session>
Requests a "tcpip-forward" action
- Author:
- Apache MINA SSHD Project
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
org.apache.sshd.common.util.closeable.AbstractCloseable.State -
Field Summary
FieldsFields inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
closeFuture, futureLock, stateFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdd a port forwarding listenerbooleanprotected org.apache.sshd.common.io.IoAcceptorcreateIoAcceptor(org.apache.sshd.common.Factory<? extends org.apache.sshd.common.io.IoHandler> handlerFactory) protected InetSocketAddressdoBind(org.apache.sshd.common.util.net.SshdSocketAddress address, org.apache.sshd.common.io.IoAcceptor acceptor) List<org.apache.sshd.common.util.net.SshdSocketAddress> getBoundLocalPortForwards(int port) org.apache.sshd.common.util.net.SshdSocketAddressgetBoundRemotePortForward(int port) final ConnectionServiceprotected Collection<PortForwardingEventListener> protected org.apache.sshd.common.io.IoAcceptororg.apache.sshd.common.util.net.SshdSocketAddressgetForwardedPort(int remotePort) protected org.apache.sshd.common.CloseableList<Map.Entry<org.apache.sshd.common.util.net.SshdSocketAddress, org.apache.sshd.common.util.net.SshdSocketAddress>> protected org.apache.sshd.common.io.IoAcceptorList<org.apache.sshd.common.util.net.SshdSocketAddress> protected voidinvokePortEventListenerSignaller(org.apache.sshd.common.util.io.functors.IOConsumer<PortForwardingEventListener> invoker) protected voidinvokePortEventListenerSignallerHolders(Collection<? extends PortForwardingEventListenerManager> holders, org.apache.sshd.common.util.io.functors.IOConsumer<PortForwardingEventListener> invoker) protected voidinvokePortEventListenerSignallerListeners(Collection<? extends PortForwardingEventListener> listeners, org.apache.sshd.common.util.io.functors.IOConsumer<PortForwardingEventListener> invoker) booleanisLocalPortForwardingStartedForPort(int port) Test if local port forwarding is startedvoidlocalPortForwardingCancelled(org.apache.sshd.common.util.net.SshdSocketAddress local) Called when the other side cancelled a remote port forward.org.apache.sshd.common.util.net.SshdSocketAddresslocalPortForwardingRequested(org.apache.sshd.common.util.net.SshdSocketAddress local) Called when the other side requested a remote port forward.protected voidpreClose()voidRemove a port forwarding listenerbooleanprotected voidsignalEstablishedDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, Throwable reason) protected voidsignalEstablishedExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote, boolean localForwarding, org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, Throwable reason) protected voidsignalEstablishingDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local) protected voidsignalEstablishingExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote, boolean localForwarding) protected voidsignalTearingDownDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress address) protected voidsignalTearingDownExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, boolean localForwarding, org.apache.sshd.common.util.net.SshdSocketAddress remote) protected voidsignalTornDownDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress address, Throwable reason) protected voidsignalTornDownExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, boolean localForwarding, org.apache.sshd.common.util.net.SshdSocketAddress remoteAddress, Throwable reason) org.apache.sshd.common.util.net.SshdSocketAddressstartDynamicPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local) Start dynamic local port forwarding using a SOCKS proxy.org.apache.sshd.common.util.net.SshdSocketAddressstartLocalPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote) Start forwarding the given local address on the client to the given address on the server.org.apache.sshd.common.util.net.SshdSocketAddressstartRemotePortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress remote, org.apache.sshd.common.util.net.SshdSocketAddress local) Start forwarding tcpip from the given address on the server to the given address on the client.voidstopDynamicPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local) Stop a previously started dynamic port forwarding.voidstopLocalPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local) Stop forwarding the given local address.voidstopRemotePortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress remote) Stop forwarding of the given remote address.toString()protected voidunbindDynamicForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local, SocksProxy proxy, InetSocketAddress bound) protected voidunbindLocalForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote, InetSocketAddress bound) Methods inherited from class org.apache.sshd.common.util.closeable.AbstractInnerCloseable
doCloseGracefully, doCloseImmediatelyMethods inherited from class org.apache.sshd.common.util.closeable.AbstractCloseable
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListenerMethods inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warnMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sshd.common.Closeable
addCloseFutureListener, close, close, isClosed, isClosing, isOpen, removeCloseFutureListenerMethods inherited from interface PortForwardingInformationProvider
isRemotePortForwardingStartedForPortMethods inherited from interface PortForwardingManager
startLocalPortForwardingMethods inherited from interface SessionHolder
getSessionContext
-
Field Details
-
STATIC_IO_MSG_RECEIVED_EVENTS
-
-
Constructor Details
-
DefaultForwarder
-
-
Method Details
-
getPortForwardingEventListenerProxy
- Specified by:
getPortForwardingEventListenerProxyin interfacePortForwardingEventListenerManager- Returns:
- A proxy listener representing all the currently registered listeners in this manager
-
addPortForwardingEventListener
Description copied from interface:PortForwardingEventListenerManagerAdd a port forwarding listener- Specified by:
addPortForwardingEventListenerin interfacePortForwardingEventListenerManager- Parameters:
listener- ThePortForwardingEventListenerto add - nevernull
-
removePortForwardingEventListener
Description copied from interface:PortForwardingEventListenerManagerRemove a port forwarding listener- Specified by:
removePortForwardingEventListenerin interfacePortForwardingEventListenerManager- Parameters:
listener- ThePortForwardingEventListenerto remove - ignored ifnull
-
getRegisteredManagers
- Specified by:
getRegisteredManagersin interfacePortForwardingEventListenerManagerHolder- Returns:
- The currently registered managers. Note: it is highly recommended that implementors return either an un-modifiable collection or a copy of the current one. Callers, should avoid modifying the retrieved value.
-
addPortForwardingEventListenerManager
- Specified by:
addPortForwardingEventListenerManagerin interfacePortForwardingEventListenerManagerHolder
-
removePortForwardingEventListenerManager
- Specified by:
removePortForwardingEventListenerManagerin interfacePortForwardingEventListenerManagerHolder
-
getSession
- Specified by:
getSessionin interfaceSessionHolder<Session>
-
getConnectionService
-
getDefaultListeners
-
startLocalPortForwarding
public org.apache.sshd.common.util.net.SshdSocketAddress startLocalPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote) throws IOException Description copied from interface:PortForwardingManagerStart forwarding the given local address on the client to the given address on the server.- Specified by:
startLocalPortForwardingin interfacePortForwardingManager- Parameters:
local- The local addressremote- The remote address- Returns:
- The bound
SshdSocketAddress - Throws:
IOException- If failed to create the requested binding
-
stopLocalPortForwarding
public void stopLocalPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local) throws IOException Description copied from interface:PortForwardingManagerStop forwarding the given local address.- Specified by:
stopLocalPortForwardingin interfacePortForwardingManager- Parameters:
local- The local address- Throws:
IOException- If failed to cancel the requested binding
-
unbindLocalForwarding
protected void unbindLocalForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote, InetSocketAddress bound) throws IOException - Throws:
IOException
-
startRemotePortForwarding
public org.apache.sshd.common.util.net.SshdSocketAddress startRemotePortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress remote, org.apache.sshd.common.util.net.SshdSocketAddress local) throws IOException Description copied from interface:PortForwardingManagerStart forwarding tcpip from the given address on the server to the given address on the client.
The remote host name is the address to bind to on the server:- "" means that connections are to be accepted on all protocol families supported by the SSH implementation
- "0.0.0.0" means to listen on all IPv4 addresses
- "::" means to listen on all IPv6 addresses
- "localhost" means to listen on all protocol families supported by the SSH implementation on loopback addresses only, [RFC3330] and RFC3513]
- "127.0.0.1" and "::1" indicate listening on the loopback interfaces for IPv4 and IPv6 respectively
- Specified by:
startRemotePortForwardingin interfacePortForwardingManager- Parameters:
remote- The remote addresslocal- The local address- Returns:
- The bound
SshdSocketAddress - Throws:
IOException- If failed to create the requested binding
-
stopRemotePortForwarding
public void stopRemotePortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress remote) throws IOException Description copied from interface:PortForwardingManagerStop forwarding of the given remote address.- Specified by:
stopRemotePortForwardingin interfacePortForwardingManager- Parameters:
remote- The remote address- Throws:
IOException- If failed to cancel the requested binding
-
signalTearingDownExplicitTunnel
protected void signalTearingDownExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, boolean localForwarding, org.apache.sshd.common.util.net.SshdSocketAddress remote) throws IOException - Throws:
IOException
-
signalTornDownExplicitTunnel
protected void signalTornDownExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, boolean localForwarding, org.apache.sshd.common.util.net.SshdSocketAddress remoteAddress, Throwable reason) throws IOException - Throws:
IOException
-
startDynamicPortForwarding
public org.apache.sshd.common.util.net.SshdSocketAddress startDynamicPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local) throws IOException Description copied from interface:PortForwardingManagerStart dynamic local port forwarding using a SOCKS proxy.- Specified by:
startDynamicPortForwardingin interfacePortForwardingManager- Parameters:
local- The local address- Returns:
- The bound
SshdSocketAddress - Throws:
IOException- If failed to create the requested binding
-
signalEstablishedDynamicTunnel
protected void signalEstablishedDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, Throwable reason) throws IOException - Throws:
IOException
-
signalEstablishingDynamicTunnel
protected void signalEstablishingDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local) throws IOException - Throws:
IOException
-
stopDynamicPortForwarding
public void stopDynamicPortForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local) throws IOException Description copied from interface:PortForwardingManagerStop a previously started dynamic port forwarding.- Specified by:
stopDynamicPortForwardingin interfacePortForwardingManager- Parameters:
local- The local address- Throws:
IOException- If failed to cancel the requested binding
-
unbindDynamicForwarding
protected void unbindDynamicForwarding(org.apache.sshd.common.util.net.SshdSocketAddress local, SocksProxy proxy, InetSocketAddress bound) throws IOException - Throws:
IOException
-
signalTearingDownDynamicTunnel
protected void signalTearingDownDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress address) throws IOException - Throws:
IOException
-
signalTornDownDynamicTunnel
protected void signalTornDownDynamicTunnel(org.apache.sshd.common.util.net.SshdSocketAddress address, Throwable reason) throws IOException - Throws:
IOException
-
getForwardedPort
public org.apache.sshd.common.util.net.SshdSocketAddress getForwardedPort(int remotePort) - Specified by:
getForwardedPortin interfaceForwarder- Parameters:
remotePort- The remote port- Returns:
- The local
SshdSocketAddressthat the remote port is forwarded to
-
localPortForwardingRequested
public org.apache.sshd.common.util.net.SshdSocketAddress localPortForwardingRequested(org.apache.sshd.common.util.net.SshdSocketAddress local) throws IOException Description copied from interface:ForwarderCalled when the other side requested a remote port forward.- Specified by:
localPortForwardingRequestedin interfaceForwarder- Parameters:
local- The request address- Returns:
- The bound local
SshdSocketAddress-nullif not allowed to forward - Throws:
IOException- If failed to handle request
-
localPortForwardingCancelled
public void localPortForwardingCancelled(org.apache.sshd.common.util.net.SshdSocketAddress local) throws IOException Description copied from interface:ForwarderCalled when the other side cancelled a remote port forward.- Specified by:
localPortForwardingCancelledin interfaceForwarder- Parameters:
local- The localSshdSocketAddress- Throws:
IOException- If failed to handle request
-
signalEstablishingExplicitTunnel
protected void signalEstablishingExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote, boolean localForwarding) throws IOException - Throws:
IOException
-
signalEstablishedExplicitTunnel
protected void signalEstablishedExplicitTunnel(org.apache.sshd.common.util.net.SshdSocketAddress local, org.apache.sshd.common.util.net.SshdSocketAddress remote, boolean localForwarding, org.apache.sshd.common.util.net.SshdSocketAddress boundAddress, Throwable reason) throws IOException - Throws:
IOException
-
invokePortEventListenerSignaller
protected void invokePortEventListenerSignaller(org.apache.sshd.common.util.io.functors.IOConsumer<PortForwardingEventListener> invoker) throws IOException - Throws:
IOException
-
invokePortEventListenerSignallerListeners
protected void invokePortEventListenerSignallerListeners(Collection<? extends PortForwardingEventListener> listeners, org.apache.sshd.common.util.io.functors.IOConsumer<PortForwardingEventListener> invoker) throws IOException - Throws:
IOException
-
invokePortEventListenerSignallerHolders
protected void invokePortEventListenerSignallerHolders(Collection<? extends PortForwardingEventListenerManager> holders, org.apache.sshd.common.util.io.functors.IOConsumer<PortForwardingEventListener> invoker) throws IOException - Throws:
IOException
-
getInnerCloseable
protected org.apache.sshd.common.Closeable getInnerCloseable()- Specified by:
getInnerCloseablein classorg.apache.sshd.common.util.closeable.AbstractInnerCloseable
-
preClose
protected void preClose()- Overrides:
preClosein classorg.apache.sshd.common.util.closeable.AbstractCloseable
-
createIoAcceptor
protected org.apache.sshd.common.io.IoAcceptor createIoAcceptor(org.apache.sshd.common.Factory<? extends org.apache.sshd.common.io.IoHandler> handlerFactory) -
getLocalIoAcceptor
protected org.apache.sshd.common.io.IoAcceptor getLocalIoAcceptor() -
getDynamicIoAcceptor
protected org.apache.sshd.common.io.IoAcceptor getDynamicIoAcceptor() -
doBind
protected InetSocketAddress doBind(org.apache.sshd.common.util.net.SshdSocketAddress address, org.apache.sshd.common.io.IoAcceptor acceptor) throws IOException - Parameters:
address- The request bind addressacceptor- AnIoAcceptorto bind addresses- Returns:
- The
InetSocketAddressto which the binding occurred - Throws:
IOException- If failed to bind
-
toString
-
getBoundLocalPortForwards
- Specified by:
getBoundLocalPortForwardsin interfacePortForwardingInformationProvider- Parameters:
port- The port number- Returns:
- The local bound
SshdSocketAddress-es for the port - See Also:
-
isLocalPortForwardingStartedForPort
public boolean isLocalPortForwardingStartedForPort(int port) Description copied from interface:PortForwardingInformationProviderTest if local port forwarding is started- Specified by:
isLocalPortForwardingStartedForPortin interfacePortForwardingInformationProvider- Parameters:
port- The local port- Returns:
trueif local port forwarding is started- See Also:
-
getLocalForwardsBindings
public List<Map.Entry<org.apache.sshd.common.util.net.SshdSocketAddress, org.apache.sshd.common.util.net.SshdSocketAddress>> getLocalForwardsBindings()- Specified by:
getLocalForwardsBindingsin interfacePortForwardingInformationProvider- Returns:
- A snapshot of the currently bound forwarded local ports as "pairs" of local/remote
SshdSocketAddress-es
-
getStartedLocalPortForwards
- Specified by:
getStartedLocalPortForwardsin interfacePortForwardingInformationProvider- Returns:
- A
Listsnapshot of the currently started local port forward bindings
-
getRemoteForwardsBindings
public List<Map.Entry<Integer, org.apache.sshd.common.util.net.SshdSocketAddress>> getRemoteForwardsBindings()- Specified by:
getRemoteForwardsBindingsin interfacePortForwardingInformationProvider- Returns:
- A snapshot of the currently bound forwarded remote ports as "pairs" of port + bound
SshdSocketAddress
-
getBoundRemotePortForward
public org.apache.sshd.common.util.net.SshdSocketAddress getBoundRemotePortForward(int port) - Specified by:
getBoundRemotePortForwardin interfacePortForwardingInformationProvider- Parameters:
port- The port number- Returns:
- The remote bound
SshdSocketAddressfor the port -nullif none bound - See Also:
-
getStartedRemotePortForwards
- Specified by:
getStartedRemotePortForwardsin interfacePortForwardingInformationProvider- Returns:
- A
NavigableSetsnapshot of the currently started remote port forwards
-