public class DefaultForwarder extends AbstractInnerCloseable implements Forwarder, SessionHolder<Session>, PortForwardingEventListenerManager
AbstractCloseable.State
Modifier and Type | Field and Description |
---|---|
static Set<ClientChannelEvent> |
STATIC_IO_MSG_RECEIVED_EVENTS |
closeFuture, futureLock, state
log
Constructor and Description |
---|
DefaultForwarder(ConnectionService service) |
doCloseGracefully, doCloseImmediately
addCloseFutureListener, builder, close, getFutureLock, isClosed, isClosing, removeCloseFutureListener
debug, debug, debug, debug, debug, error, error, error, error, error, getSimplifiedLogger, info, info, warn, warn, warn, warn, warn, warn, warn, warn
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
startLocalPortForwarding
isRemotePortForwardingStartedForPort
addCloseFutureListener, close, close, close, getMaxCloseWaitTime, isClosed, isClosing, isOpen, removeCloseFutureListener
getSessionContext
public static final Set<ClientChannelEvent> STATIC_IO_MSG_RECEIVED_EVENTS
public DefaultForwarder(ConnectionService service)
public PortForwardingEventListener getPortForwardingEventListenerProxy()
getPortForwardingEventListenerProxy
in interface PortForwardingEventListenerManager
public void addPortForwardingEventListener(PortForwardingEventListener listener)
PortForwardingEventListenerManager
addPortForwardingEventListener
in interface PortForwardingEventListenerManager
listener
- The PortForwardingEventListener
to add - never null
public void removePortForwardingEventListener(PortForwardingEventListener listener)
PortForwardingEventListenerManager
removePortForwardingEventListener
in interface PortForwardingEventListenerManager
listener
- The PortForwardingEventListener
to remove - ignored if null
public Collection<PortForwardingEventListenerManager> getRegisteredManagers()
getRegisteredManagers
in interface PortForwardingEventListenerManagerHolder
public boolean addPortForwardingEventListenerManager(PortForwardingEventListenerManager manager)
addPortForwardingEventListenerManager
in interface PortForwardingEventListenerManagerHolder
public boolean removePortForwardingEventListenerManager(PortForwardingEventListenerManager manager)
removePortForwardingEventListenerManager
in interface PortForwardingEventListenerManagerHolder
public Session getSession()
getSession
in interface SessionHolder<Session>
public final ConnectionService getConnectionService()
protected Collection<PortForwardingEventListener> getDefaultListeners()
public SshdSocketAddress startLocalPortForwarding(SshdSocketAddress local, SshdSocketAddress remote) throws IOException
PortForwardingManager
startLocalPortForwarding
in interface PortForwardingManager
local
- The local addressremote
- The remote addressSshdSocketAddress
IOException
- If failed to create the requested bindingpublic void stopLocalPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManager
stopLocalPortForwarding
in interface PortForwardingManager
local
- The local addressIOException
- If failed to cancel the requested bindingprotected void unbindLocalForwarding(SshdSocketAddress local, SshdSocketAddress remote, InetSocketAddress bound) throws IOException
IOException
public SshdSocketAddress startRemotePortForwarding(SshdSocketAddress remote, SshdSocketAddress local) throws IOException
PortForwardingManager
Start 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:startRemotePortForwarding
in interface PortForwardingManager
remote
- The remote addresslocal
- The local addressSshdSocketAddress
IOException
- If failed to create the requested bindingpublic void stopRemotePortForwarding(SshdSocketAddress remote) throws IOException
PortForwardingManager
stopRemotePortForwarding
in interface PortForwardingManager
remote
- The remote addressIOException
- If failed to cancel the requested bindingprotected void signalTearingDownExplicitTunnel(SshdSocketAddress boundAddress, boolean localForwarding, SshdSocketAddress remote) throws IOException
IOException
protected void signalTearingDownExplicitTunnel(PortForwardingEventListener listener, SshdSocketAddress boundAddress, boolean localForwarding, SshdSocketAddress remoteAddress) throws IOException
IOException
protected void signalTornDownExplicitTunnel(SshdSocketAddress boundAddress, boolean localForwarding, SshdSocketAddress remoteAddress, Throwable reason) throws IOException
IOException
protected void signalTornDownExplicitTunnel(PortForwardingEventListener listener, SshdSocketAddress boundAddress, boolean localForwarding, SshdSocketAddress remoteAddress, Throwable reason) throws IOException
IOException
public SshdSocketAddress startDynamicPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManager
startDynamicPortForwarding
in interface PortForwardingManager
local
- The local addressSshdSocketAddress
IOException
- If failed to create the requested bindingprotected void signalEstablishedDynamicTunnel(SshdSocketAddress local, SshdSocketAddress boundAddress, Throwable reason) throws IOException
IOException
protected void signalEstablishedDynamicTunnel(PortForwardingEventListener listener, SshdSocketAddress local, SshdSocketAddress boundAddress, Throwable reason) throws IOException
IOException
protected void signalEstablishingDynamicTunnel(SshdSocketAddress local) throws IOException
IOException
protected void signalEstablishingDynamicTunnel(PortForwardingEventListener listener, SshdSocketAddress local) throws IOException
IOException
public void stopDynamicPortForwarding(SshdSocketAddress local) throws IOException
PortForwardingManager
stopDynamicPortForwarding
in interface PortForwardingManager
local
- The local addressIOException
- If failed to cancel the requested bindingprotected void unbindDynamicForwarding(SshdSocketAddress local, SocksProxy proxy, InetSocketAddress bound) throws IOException
IOException
protected void signalTearingDownDynamicTunnel(SshdSocketAddress address) throws IOException
IOException
protected void signalTearingDownDynamicTunnel(PortForwardingEventListener listener, SshdSocketAddress address) throws IOException
IOException
protected void signalTornDownDynamicTunnel(SshdSocketAddress address, Throwable reason) throws IOException
IOException
protected void signalTornDownDynamicTunnel(PortForwardingEventListener listener, SshdSocketAddress address, Throwable reason) throws IOException
IOException
public SshdSocketAddress getForwardedPort(int remotePort)
getForwardedPort
in interface Forwarder
remotePort
- The remote portSshdSocketAddress
that the remote port is forwarded topublic SshdSocketAddress localPortForwardingRequested(SshdSocketAddress local) throws IOException
Forwarder
localPortForwardingRequested
in interface Forwarder
local
- The request addressSshdSocketAddress
- null
if not allowed to forwardIOException
- If failed to handle requestpublic void localPortForwardingCancelled(SshdSocketAddress local) throws IOException
Forwarder
localPortForwardingCancelled
in interface Forwarder
local
- The local SshdSocketAddress
IOException
- If failed to handle requestprotected void signalEstablishingExplicitTunnel(SshdSocketAddress local, SshdSocketAddress remote, boolean localForwarding) throws IOException
IOException
protected void signalEstablishingExplicitTunnel(PortForwardingEventListener listener, SshdSocketAddress local, SshdSocketAddress remote, boolean localForwarding) throws IOException
IOException
protected void signalEstablishedExplicitTunnel(SshdSocketAddress local, SshdSocketAddress remote, boolean localForwarding, SshdSocketAddress boundAddress, Throwable reason) throws IOException
IOException
protected void signalEstablishedExplicitTunnel(PortForwardingEventListener listener, SshdSocketAddress local, SshdSocketAddress remote, boolean localForwarding, SshdSocketAddress boundAddress, Throwable reason) throws IOException
IOException
protected void invokePortEventListenerSignaller(Invoker<PortForwardingEventListener,Void> invoker) throws Throwable
Throwable
protected void invokePortEventListenerSignallerListeners(Collection<? extends PortForwardingEventListener> listeners, Invoker<PortForwardingEventListener,Void> invoker) throws Throwable
Throwable
protected void invokePortEventListenerSignallerHolders(Collection<? extends PortForwardingEventListenerManager> holders, Invoker<PortForwardingEventListener,Void> invoker) throws Throwable
Throwable
protected Closeable getInnerCloseable()
getInnerCloseable
in class AbstractInnerCloseable
protected void preClose()
AbstractCloseable
preClose
in class AbstractCloseable
protected IoAcceptor createIoAcceptor(Factory<? extends IoHandler> handlerFactory)
protected IoAcceptor getLocalIoAcceptor()
protected IoAcceptor getDynamicIoAcceptor()
protected InetSocketAddress doBind(SshdSocketAddress address, IoAcceptor acceptor) throws IOException
address
- The request bind addressacceptor
- An IoAcceptor
to bind addressesInetSocketAddress
to which the binding occurredIOException
- If failed to bindpublic List<SshdSocketAddress> getBoundLocalPortForwards(int port)
getBoundLocalPortForwards
in interface PortForwardingInformationProvider
port
- The port numberSshdSocketAddress
-es for the portisLocalPortForwardingStartedForPort
,
PortForwardingInformationProvider.getStartedLocalPortForwards()
public boolean isLocalPortForwardingStartedForPort(int port)
PortForwardingInformationProvider
isLocalPortForwardingStartedForPort
in interface PortForwardingInformationProvider
port
- The local porttrue
if local port forwarding is startedgetBoundLocalPortForwards
public List<Map.Entry<SshdSocketAddress,SshdSocketAddress>> getLocalForwardsBindings()
getLocalForwardsBindings
in interface PortForwardingInformationProvider
SshdSocketAddress
-espublic List<SshdSocketAddress> getStartedLocalPortForwards()
getStartedLocalPortForwards
in interface PortForwardingInformationProvider
List
snapshot of the currently started local port forward bindingspublic List<Map.Entry<Integer,SshdSocketAddress>> getRemoteForwardsBindings()
getRemoteForwardsBindings
in interface PortForwardingInformationProvider
SshdSocketAddress
public SshdSocketAddress getBoundRemotePortForward(int port)
getBoundRemotePortForward
in interface PortForwardingInformationProvider
port
- The port numberSshdSocketAddress
for the port - null
if none boundisRemotePortForwardingStartedForPort
,
PortForwardingInformationProvider.getStartedRemotePortForwards()
public NavigableSet<Integer> getStartedRemotePortForwards()
getStartedRemotePortForwards
in interface PortForwardingInformationProvider
NavigableSet
snapshot of the currently started remote port forwardsCopyright © 2008–2024 The Apache Software Foundation. All rights reserved.