@@ -64,7 +64,23 @@ class ProxyProtocol
6464 : version(pp_ver), ip_family(family), src_addr(src), dst_addr(dst)
6565 {
6666 }
67- ~ProxyProtocol () { ats_free (additional_data); }
67+ ProxyProtocol (const ProxyProtocol &other)
68+ : version(other.version), ip_family(other.ip_family), src_addr(other.src_addr), dst_addr(other.dst_addr)
69+ {
70+ if (!other.additional_data .empty ()) {
71+ set_additional_data (other.additional_data );
72+ }
73+ }
74+ ProxyProtocol (ProxyProtocol &&other)
75+ : version(other.version), ip_family(other.ip_family), src_addr(other.src_addr), dst_addr(other.dst_addr)
76+ {
77+ if (!other.additional_data .empty ()) {
78+ set_additional_data (other.additional_data );
79+ }
80+ other.additional_data .clear ();
81+ other.tlv .clear ();
82+ }
83+ ~ProxyProtocol () = default ;
6884 int set_additional_data (std::string_view data);
6985 void set_ipv4_addrs (in_addr_t src_addr, uint16_t src_port, in_addr_t dst_addr, uint16_t dst_port);
7086 void set_ipv6_addrs (const in6_addr &src_addr, uint16_t src_port, const in6_addr &dst_addr, uint16_t dst_port);
@@ -78,8 +94,46 @@ class ProxyProtocol
7894 IpEndpoint dst_addr = {};
7995 std::unordered_map<uint8_t , std::string_view> tlv;
8096
97+ ProxyProtocol &
98+ operator =(const ProxyProtocol &other)
99+ {
100+ if (&other == this ) {
101+ return *this ;
102+ }
103+ version = other.version ;
104+ ip_family = other.ip_family ;
105+ src_addr = other.src_addr ;
106+ dst_addr = other.dst_addr ;
107+ if (!other.additional_data .empty ()) {
108+ set_additional_data (other.additional_data );
109+ } else {
110+ additional_data.clear ();
111+ tlv.clear ();
112+ }
113+ return *this ;
114+ }
115+
116+ ProxyProtocol &
117+ operator =(ProxyProtocol &&other)
118+ {
119+ version = other.version ;
120+ ip_family = other.ip_family ;
121+ src_addr = other.src_addr ;
122+ dst_addr = other.dst_addr ;
123+
124+ additional_data.clear ();
125+ tlv.clear ();
126+
127+ if (!other.additional_data .empty ()) {
128+ set_additional_data (other.additional_data );
129+ }
130+ other.additional_data .clear ();
131+ other.tlv .clear ();
132+ return *this ;
133+ }
134+
81135private:
82- char * additional_data = nullptr ;
136+ std::string additional_data;
83137};
84138
85139const size_t PPv1_CONNECTION_HEADER_LEN_MAX = 108 ;
0 commit comments