remote_ip v0.2.0 RemoteIp.Headers.Forwarded View Source

RFC 7239 compliant parser for Forwarded headers.

Link to this section Summary

Functions

Given a Forwarded header's string value, parses out IP addresses from the for= parameter.

Link to this section Types

Link to this section Functions

Link to this function

parse(header)

View Source
parse(header()) :: [ip()]

Given a Forwarded header's string value, parses out IP addresses from the for= parameter.

Examples

iex> RemoteIp.Headers.Forwarded.parse("for=1.2.3.4;by=2.3.4.5")
[{1, 2, 3, 4}]

iex> RemoteIp.Headers.Forwarded.parse("for=\"[::1]\", for=\"[::2]\"")
[{0, 0, 0, 0, 0, 0, 0, 1}, {0, 0, 0, 0, 0, 0, 0, 2}]

iex> RemoteIp.Headers.Forwarded.parse("invalid")
[]