aboutsummaryrefslogtreecommitdiffstats
path: root/doc/src/manual/ranch_proxy_header.header.asciidoc
blob: c551110177a9b48fb5ddc630d41b677359c622bc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
= ranch_proxy_header:header(3)

== Name

ranch_proxy_header:header - Build a PROXY protocol header

== Description

[source,erlang]
----
header(ProxyInfo)            -> header(ProxyInfo, #{})
header(ProxyInfo, BuildOpts) -> iodata()

ProxyInfo :: ranch_proxy_header:proxy_info()
BuildOpts :: #{
    checksum => crc32c,
    padding  => pos_integer() %% >= 3
}
----

Build a PROXY protocol header.

== Arguments

ProxyInfo::

The proxy information to encode.

BuildOpts::

Options to control whether to add a checksum or padding
should be included in the encoded PROXY protocol header.

== Return value

The PROXY protocol header is returned.

== Changelog

* *1.7*: Function introduced.

== Examples

.Build a PROXY protocol header
[source,erlang]
----
ProxyInfo = #{
    version => 2,
    command => proxy,

    transport_family   => ipv4,
    transport_protocol => stream,

    src_address  => {192, 168, 1, 11},
    src_port     => 54321,
    dest_address => {192, 168, 1, 42},
    dest_port    => 443
},
Data = ranch_proxy_header:parse(ProxyInfo).
----

.Build a PROXY protocol header with checksum and padding
[source,erlang]
----
Data = ranch_proxy_header:parse(ProxyInfo, #{
    checksum => crc32c,
    padding  => 7
}).
----

== See also

link:man:ranch_proxy_header:header(3)[ranch_proxy_header:header(3)],
link:man:ranch_proxy_header(3)[ranch_proxy_header(3)]