PROXY protocol v1 or v2 header. More...

#include <Header.h>

Inheritance diagram for ProxyProtocol::Header:
Collaboration diagram for ProxyProtocol::Header:

Public Types

typedef RefCount< HeaderPointer
 
typedef std::vector< Two::TlvTlvs
 

Public Member Functions

 Header (const SBuf &ver, const Two::Command cmd)
 
SBuf toMime () const
 
SBuf getValues (const uint32_t headerType, const char delimiter=',') const
 
SBuf getElem (const uint32_t headerType, const char *member, const char delimiter) const
 
const SBufversion () const
 PROXY protocol version. More...
 
bool hasForwardedAddresses () const
 whether source and destination addresses are valid addresses of the original "client" connection More...
 
void ignoreAddresses ()
 marks the header as lacking address information More...
 
bool hasAddresses () const
 whether the header relays address information (including LOCAL connections) More...
 
const SBufaddressFamily () const
 

Public Attributes

Ip::Address sourceAddress
 source address of the client connection More...
 
Ip::Address destinationAddress
 intended destination address of the client connection More...
 
Tlvs tlvs
 empty in v1 headers and when ignored in v2 headers More...
 

Private Member Functions

bool localConnection () const
 

Private Attributes

SBuf version_
 PROXY protocol version. More...
 
Two::Command command_
 
bool ignoreAddresses_
 true if the header relays no address information More...
 

Detailed Description

Definition at line 22 of file Header.h.

Member Typedef Documentation

◆ Pointer

Definition at line 25 of file Header.h.

◆ Tlvs

Definition at line 26 of file Header.h.

Constructor & Destructor Documentation

◆ Header()

ProxyProtocol::Header::Header ( const SBuf ver,
const Two::Command  cmd 
)

Definition at line 18 of file Header.cc.

Member Function Documentation

◆ addressFamily()

const SBuf & ProxyProtocol::Header::addressFamily ( ) const
Returns
"4" or "6" if both source and destination addresses are IPv4 or IPv6
"mix" otherwise

Definition at line 97 of file Header.cc.

◆ getElem()

SBuf ProxyProtocol::Header::getElem ( const uint32_t  headerType,
const char *  member,
const char  delimiter 
) const

Searches for the first key=value pair occurrence within the value for the provided TLV type. Assumes that the TLV value is a delimiter-separated list.

Returns
the value of the found pair or the empty string.

Definition at line 90 of file Header.cc.

References getListMember(), and SBufToString().

◆ getValues()

SBuf ProxyProtocol::Header::getValues ( const uint32_t  headerType,
const char  delimiter = ',' 
) const

◆ hasAddresses()

bool ProxyProtocol::Header::hasAddresses ( ) const
inline

Definition at line 54 of file Header.h.

References ignoreAddresses_.

Referenced by hasForwardedAddresses().

◆ hasForwardedAddresses()

bool ProxyProtocol::Header::hasForwardedAddresses ( ) const
inline

Definition at line 48 of file Header.h.

References hasAddresses(), and localConnection().

◆ ignoreAddresses()

void ProxyProtocol::Header::ignoreAddresses ( )
inline

Definition at line 51 of file Header.h.

References ignoreAddresses_.

◆ localConnection()

bool ProxyProtocol::Header::localConnection ( ) const
inlineprivate

Whether the connection over PROXY protocol is 'cmdLocal'. Such connections are established without being relayed. Received addresses and TLVs are discarded in this mode.

Definition at line 71 of file Header.h.

References ProxyProtocol::Two::cmdLocal, and command_.

Referenced by hasForwardedAddresses().

◆ toMime()

SBuf ProxyProtocol::Header::toMime ( ) const

HTTP header-like string representation of the header. The returned string has one line per pseudo header and one line per TLV (if any).

Definition at line 25 of file Header.cc.

References SBufStream::buf(), EnumRange(), ProxyProtocol::Two::htPseudoBegin, ProxyProtocol::Two::htPseudoEnd, and ProxyProtocol::PseudoFieldTypeToFieldName().

◆ version()

const SBuf & ProxyProtocol::Header::version ( ) const
inline

Definition at line 45 of file Header.h.

References version_.

Member Data Documentation

◆ command_

Two::Command ProxyProtocol::Header::command_
private

for v2 headers: the command field for v1 headers: Two::cmdProxy

Definition at line 78 of file Header.h.

Referenced by localConnection().

◆ destinationAddress

Ip::Address ProxyProtocol::Header::destinationAddress

Definition at line 63 of file Header.h.

◆ ignoreAddresses_

bool ProxyProtocol::Header::ignoreAddresses_
private

Definition at line 81 of file Header.h.

Referenced by hasAddresses(), and ignoreAddresses().

◆ sourceAddress

Ip::Address ProxyProtocol::Header::sourceAddress

Definition at line 61 of file Header.h.

◆ tlvs

Tlvs ProxyProtocol::Header::tlvs

Definition at line 65 of file Header.h.

◆ version_

SBuf ProxyProtocol::Header::version_
private

Definition at line 74 of file Header.h.

Referenced by version().


The documentation for this class was generated from the following files:

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors