Class ProxyProtocolAcceptor
- java.lang.Object
-
- org.apache.sshd.common.util.logging.AbstractLoggingBean
-
- org.apache.sshd.contrib.server.session.proxyprotocol.ProxyProtocolAcceptor
-
- All Implemented Interfaces:
ServerProxyAcceptor
- Direct Known Subclasses:
ProxyProtocolV2Acceptor
public class ProxyProtocolAcceptor extends AbstractLoggingBean implements ServerProxyAcceptor
A working prototype to support PROXY protocol as described in HAProxy Documentation.- See Also:
- Tony Bussieres contribution
-
-
Field Summary
Fields Modifier and Type Field Description static intMAX_PROXY_HEADER_LENGTHstatic java.lang.StringPROX_PROTOCOL_PREFIXprivate static byte[]PROXY_HEADER-
Fields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log
-
-
Constructor Summary
Constructors Constructor Description ProxyProtocolAcceptor()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanacceptServerProxyMetadata(ServerSession session, Buffer buffer)Invoked before any attempt is made to retrieve the SSH client identification data of the standard SSH protocol.protected booleanparseProxyHeader(ServerSession session, java.lang.String proxyHeader, int markPosition, Buffer buffer)
-
-
-
Field Detail
-
MAX_PROXY_HEADER_LENGTH
public static final int MAX_PROXY_HEADER_LENGTH
- See Also:
- Constant Field Values
-
PROX_PROTOCOL_PREFIX
public static final java.lang.String PROX_PROTOCOL_PREFIX
- See Also:
- Constant Field Values
-
PROXY_HEADER
private static final byte[] PROXY_HEADER
-
-
Method Detail
-
acceptServerProxyMetadata
public boolean acceptServerProxyMetadata(ServerSession session, Buffer buffer) throws java.lang.Exception
Description copied from interface:ServerProxyAcceptorInvoked before any attempt is made to retrieve the SSH client identification data of the standard SSH protocol. The implementor should extract whatever data it needs from the data buffer. Note: the method may be called several times for the same session even though the original proxy data was successfully extracted. This happens in case the client identification line following it is incomplete and thus requires waiting for more incoming packets.- Specified by:
acceptServerProxyMetadatain interfaceServerProxyAcceptor- Parameters:
session- TheServerSessioninstancebuffer- The received dataBuffer- if not the 1st time this method is called because data was lacking on last invocation, then the buffer is guaranteed to contain the data from all the previous incomplete invocations plus any new received data. If not enough information is available, the buffer's read position should be restored to its original value when the method was invoked.- Returns:
trueif successfully extracted the remote client peer meta-data,falseif more data is required. Upon successful return the buffer read position is assumed to indicate the first character of the SSH identification line- Throws:
java.lang.Exception- If failed to correctly extract and parse the meta-data, in which case the session will be closed
-
parseProxyHeader
protected boolean parseProxyHeader(ServerSession session, java.lang.String proxyHeader, int markPosition, Buffer buffer) throws java.lang.Exception
- Throws:
java.lang.Exception
-
-