ranch_proxy_header.header.asciidoc 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. = ranch_proxy_header:header(3)
  2. == Name
  3. ranch_proxy_header:header - Build a PROXY protocol header
  4. == Description
  5. [source,erlang]
  6. ----
  7. header(ProxyInfo) -> header(ProxyInfo, #{})
  8. header(ProxyInfo, BuildOpts) -> iodata()
  9. ProxyInfo :: ranch_proxy_header:proxy_info()
  10. BuildOpts :: #{
  11. checksum => crc32c,
  12. padding => pos_integer() %% >= 3
  13. }
  14. ----
  15. Build a PROXY protocol header.
  16. == Arguments
  17. ProxyInfo::
  18. The proxy information to encode.
  19. BuildOpts::
  20. Options to control whether to add a checksum or padding
  21. should be included in the encoded PROXY protocol header.
  22. == Return value
  23. The PROXY protocol header is returned.
  24. == Changelog
  25. * *1.7*: Function introduced.
  26. == Examples
  27. .Build a PROXY protocol header
  28. [source,erlang]
  29. ----
  30. ProxyInfo = #{
  31. version => 2,
  32. command => proxy,
  33. transport_family => ipv4,
  34. transport_protocol => stream,
  35. src_address => {192, 168, 1, 11},
  36. src_port => 54321,
  37. dest_address => {192, 168, 1, 42},
  38. dest_port => 443
  39. },
  40. Data = ranch_proxy_header:parse(ProxyInfo).
  41. ----
  42. .Build a PROXY protocol header with checksum and padding
  43. [source,erlang]
  44. ----
  45. Data = ranch_proxy_header:parse(ProxyInfo, #{
  46. checksum => crc32c,
  47. padding => 7
  48. }).
  49. ----
  50. == See also
  51. link:man:ranch_proxy_header:header(3)[ranch_proxy_header:header(3)],
  52. link:man:ranch_proxy_header(3)[ranch_proxy_header(3)]