Class ProxyProtocolV2Acceptor
java.lang.Object
org.apache.sshd.common.util.logging.AbstractLoggingBean
org.apache.sshd.contrib.server.session.proxyprotocol.ProxyProtocolAcceptor
org.apache.sshd.contrib.server.session.proxyprotocolv2.ProxyProtocolV2Acceptor
- All Implemented Interfaces:
ServerProxyAcceptor
A working prototype to support PROXY protocol v2 as described in
HAProxy Documentation.
This ServerProxyAcceptor can process PROXY protocol v1 and v2.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final charprivate static final byte[]Fields inherited from class org.apache.sshd.contrib.server.session.proxyprotocol.ProxyProtocolAcceptor
MAX_PROXY_HEADER_LENGTH, PROX_PROTOCOL_PREFIXFields inherited from class org.apache.sshd.common.util.logging.AbstractLoggingBean
log -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanacceptServerProxyMetadata(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, String proxyHeader, int markPosition, Buffer buffer) protected booleanreadProxyV2Header(ServerSession session, int markPosition, Buffer buffer)
-
Field Details
-
PROXY_V2_HEADER
private static final byte[] PROXY_V2_HEADER -
FIELD_SEPARATOR
private static final char FIELD_SEPARATOR- See Also:
-
-
Constructor Details
-
ProxyProtocolV2Acceptor
public ProxyProtocolV2Acceptor()
-
-
Method Details
-
acceptServerProxyMetadata
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- Overrides:
acceptServerProxyMetadatain classProxyProtocolAcceptor- 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:
Exception- If failed to correctly extract and parse the meta-data, in which case the session will be closed
-
readProxyV2Header
protected boolean readProxyV2Header(ServerSession session, int markPosition, Buffer buffer) throws Exception - Throws:
Exception
-
parseProxyHeader
protected boolean parseProxyHeader(ServerSession session, String proxyHeader, int markPosition, Buffer buffer) throws Exception - Overrides:
parseProxyHeaderin classProxyProtocolAcceptor- Throws:
Exception
-