MCPcopy Create free account
hub / github.com/apache/trafficserver / do_outbound_proxy_protocol

Function do_outbound_proxy_protocol

src/proxy/http/HttpSM.cc:146–176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144} // namespace
145
146int64_t
147do_outbound_proxy_protocol(MIOBuffer *miob, NetVConnection *vc_out, NetVConnection *vc_in, int conf)
148{
149 ink_release_assert(conf >= 0);
150
151 ProxyProtocol info = vc_in->get_proxy_protocol_info();
152 ProxyProtocolVersion pp_version = proxy_protocol_version_cast(conf);
153
154 if (info.version == ProxyProtocolVersion::UNDEFINED) {
155 if (conf == 0) {
156 // nothing to forward
157 return 0;
158 } else {
159 Dbg(dbg_ctl_proxyprotocol, "vc_in had no Proxy Protocol. Manufacturing from the vc_in socket.");
160 // set info from incoming NetVConnection
161 IpEndpoint local = vc_in->get_local_endpoint();
162 info = ProxyProtocol{pp_version, local.family(), vc_in->get_remote_endpoint(), local};
163 }
164 }
165
166 vc_out->set_proxy_protocol_info(info);
167
168 IOBufferBlock *block = miob->first_write_block();
169 size_t len = proxy_protocol_build(reinterpret_cast<uint8_t *>(block->buf()), block->write_avail(), info, pp_version);
170
171 if (len > 0) {
172 miob->fill(len);
173 }
174
175 return len;
176}
177
178ClassAllocator<HttpSM> httpSMAllocator("httpSMAllocator");
179

Callers 2

setup_blind_tunnelMethod · 0.85

Calls 8

proxy_protocol_buildFunction · 0.85
familyMethod · 0.45
first_write_blockMethod · 0.45
bufMethod · 0.45
write_availMethod · 0.45
fillMethod · 0.45

Tested by

no test coverage detected