| 144 | } // namespace |
| 145 | |
| 146 | int64_t |
| 147 | do_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 | |
| 178 | ClassAllocator<HttpSM> httpSMAllocator("httpSMAllocator"); |
| 179 |
no test coverage detected