PROXY Protocol Parser */
| 457 | PROXY Protocol Parser |
| 458 | */ |
| 459 | size_t |
| 460 | proxy_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 |
no test coverage detected