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_SRC_PROXYP_HEADER_H
10 #define SQUID_SRC_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 
19 namespace ProxyProtocol {
20 
22 class Header: public RefCountable
23 {
24 public:
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 
51  void ignoreAddresses() { ignoreAddresses_ = true; }
52 
54  bool hasAddresses() const { return !ignoreAddresses_; }
55 
58  const SBuf &addressFamily() const;
59 
66 
67 private:
71  bool localConnection() const { return command_ == Two::cmdLocal; }
72 
75 
79 
82 };
83 
84 } // namespace ProxyProtocol
85 
86 #endif /* SQUID_SRC_PROXYP_HEADER_H */
87 
SBuf getElem(const uint32_t headerType, const char *member, const char delimiter) const
Definition: Header.cc:90
const SBuf & addressFamily() const
Definition: Header.cc:97
Definition: SBuf.h:93
Tlvs tlvs
empty in v1 headers and when ignored in v2 headers
Definition: Header.h:65
PROXY protocol v1 or v2 header.
Definition: Header.h:22
static const char * delimiter
Definition: ldap_backend.cc:65
bool hasForwardedAddresses() const
whether source and destination addresses are valid addresses of the original "client" connection
Definition: Header.h:48
SBuf version_
PROXY protocol version.
Definition: Header.h:74
Two::Command command_
Definition: Header.h:78
Ip::Address sourceAddress
source address of the client connection
Definition: Header.h:61
const SBuf & version() const
PROXY protocol version.
Definition: Header.h:45
bool localConnection() const
Definition: Header.h:71
bool ignoreAddresses_
true if the header relays no address information
Definition: Header.h:81
SBuf toMime() const
Definition: Header.cc:25
SBuf getValues(const uint32_t headerType, const char delimiter=',') const
Definition: Header.cc:40
Ip::Address destinationAddress
intended destination address of the client connection
Definition: Header.h:63
bool hasAddresses() const
whether the header relays address information (including LOCAL connections)
Definition: Header.h:54
void ignoreAddresses()
marks the header as lacking address information
Definition: Header.h:51
RefCount< Header > Pointer
Definition: Header.h:25
Command
PROXY protocol 'command' field value.
Definition: Elements.h:48
std::vector< Two::Tlv > Tlvs
Definition: Header.h:26
Header(const SBuf &ver, const Two::Command cmd)
Definition: Header.cc:18

 

Introduction

Documentation

Support

Miscellaneous