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

Function proxy_protocol_parse

src/iocore/net/ProxyProtocol.cc:459–477  ·  view source on GitHub ↗

PROXY Protocol Parser */

Source from the content-addressed store, hash-verified

457 PROXY Protocol Parser
458 */
459size_t
460proxy_protocol_parse(ProxyProtocol *pp_info, swoc::TextView tv)
461{
462 size_t len = 0;
463
464 // Parse the TextView before moving the bytes in the buffer
465 if (tv.size() >= PPv1_CONNECTION_HEADER_LEN_MIN && tv.starts_with(PPv1_CONNECTION_PREFACE)) {
466 // Client must send at least 15 bytes to get a reasonable match.
467 len = proxy_protocol_v1_parse(pp_info, tv);
468 } else if (tv.size() >= PPv2_CONNECTION_HEADER_LEN && tv.starts_with(PPv2_CONNECTION_PREFACE)) {
469 len = proxy_protocol_v2_parse(pp_info, tv);
470 } else {
471 // if we don't have the PROXY preface, we don't have a ProxyProtocol header
472 // TODO: print hexdump of buffer safely
473 Dbg(dbg_ctl_proxyprotocol, "failed to find ProxyProtocol preface in the first %zu bytes", tv.size());
474 }
475
476 return len;
477}
478
479/**
480 PROXY Protocol Builder

Callers 3

has_proxy_protocolMethod · 0.85
LLVMFuzzerTestOneInputFunction · 0.85

Calls 4

proxy_protocol_v1_parseFunction · 0.85
proxy_protocol_v2_parseFunction · 0.85
sizeMethod · 0.45
starts_withMethod · 0.45

Tested by

no test coverage detected