Header.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 1996-2023 The Squid Software Foundation and contributors
3 *
4 * Squid software is distributed under GPLv2+ license and includes
5 * contributions from numerous individuals and organizations.
6 * Please see the COPYING and CONTRIBUTORS files for details.
7 */
8
9#ifndef SQUID_PROXYP_HEADER_H
10#define SQUID_PROXYP_HEADER_H
11
12#include "base/RefCount.h"
13#include "ip/Address.h"
14#include "proxyp/Elements.h"
15#include "sbuf/SBuf.h"
16
17#include <vector>
18
19namespace ProxyProtocol {
20
22class Header: public RefCountable
23{
24public:
26 typedef std::vector<Two::Tlv> Tlvs;
27
28 Header(const SBuf &ver, const Two::Command cmd);
29
33 SBuf toMime() const;
34
36 SBuf getValues(const uint32_t headerType, const char delimiter = ',') const;
37
42 SBuf getElem(const uint32_t headerType, const char *member, const char delimiter) const;
43
45 const SBuf &version() const { return version_; }
46
48 bool hasForwardedAddresses() const { return !localConnection() && hasAddresses(); }
49
52
54 bool hasAddresses() const { return !ignoreAddresses_; }
55
58 const SBuf &addressFamily() const;
59
66
67private:
71 bool localConnection() const { return command_ == Two::cmdLocal; }
72
75
79
82};
83
84} // namespace ProxyProtocol
85
86#endif
87
#define RefCountable
The locking interface for use on Reference-Counted classes.
Definition: Lock.h:66
PROXY protocol v1 or v2 header.
Definition: Header.h:23
SBuf getElem(const uint32_t headerType, const char *member, const char delimiter) const
Definition: Header.cc:90
SBuf toMime() const
Definition: Header.cc:25
bool hasAddresses() const
whether the header relays address information (including LOCAL connections)
Definition: Header.h:54
Two::Command command_
Definition: Header.h:78
std::vector< Two::Tlv > Tlvs
Definition: Header.h:26
SBuf getValues(const uint32_t headerType, const char delimiter=',') const
Definition: Header.cc:40
Header(const SBuf &ver, const Two::Command cmd)
Definition: Header.cc:18
bool ignoreAddresses_
true if the header relays no address information
Definition: Header.h:81
void ignoreAddresses()
marks the header as lacking address information
Definition: Header.h:51
RefCount< Header > Pointer
Definition: Header.h:25
bool hasForwardedAddresses() const
whether source and destination addresses are valid addresses of the original "client" connection
Definition: Header.h:48
Ip::Address sourceAddress
source address of the client connection
Definition: Header.h:61
SBuf version_
PROXY protocol version.
Definition: Header.h:74
bool localConnection() const
Definition: Header.h:71
const SBuf & version() const
PROXY protocol version.
Definition: Header.h:45
const SBuf & addressFamily() const
Definition: Header.cc:97
Tlvs tlvs
empty in v1 headers and when ignored in v2 headers
Definition: Header.h:65
Ip::Address destinationAddress
intended destination address of the client connection
Definition: Header.h:63
Definition: SBuf.h:94
static const char * delimiter
Definition: ldap_backend.cc:65
Command
PROXY protocol 'command' field value.
Definition: Elements.h:48

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors