plug_ip_whitelist v1.2.0 Plug.IpWhitelist.EnvironmentVariableParser View Source

IP Whitelists often need to be stored as an environment variable. This module provides functionality for parsing a list of IP ranges out of a string which could be stored in your application’s environment variables. Example:

"1.1.1.1-1.1.1.1 2.3.4.5-6.7.8.9"

Link to this section Summary

Functions

Given a string of ip ranges, convert to a list of ip ranges Example input:

"1.1.1.1-1.1.1.1 2.3.4.5-6.7.8.9"

Example output:

[
  {{1, 1, 1, 1}, {1, 1, 1, 1}},
  {{2, 3, 4, 5}, {6, 7, 8, 9}}
]

Given a string which contains an ip address, convert to an ip_address Example input:

"1.1.1.1"

Example output:

{1, 1, 1, 1}

Given a string which contains an integer, convert to an integer (ip_byte) Example input:

"1"

Example output:

1

Given a string which contains an ip range, convert to an ip_range Example input:

1.1.1.1-1.1.1.1

Example output:

{{1, 1, 1, 1}, {1, 1, 1, 1}}

Link to this section Functions

Link to this function parse(string_ip_whitelist) View Source
parse(String.t()) :: [IpWhitelist.ip_range(), ...]

Given a string of ip ranges, convert to a list of ip ranges Example input:

"1.1.1.1-1.1.1.1 2.3.4.5-6.7.8.9"

Example output:

[
  {{1, 1, 1, 1}, {1, 1, 1, 1}},
  {{2, 3, 4, 5}, {6, 7, 8, 9}}
]
Link to this function parse_ip_address(string_ip_address) View Source
parse_ip_address(String.t()) :: IpWhitelist.ip_address()

Given a string which contains an ip address, convert to an ip_address Example input:

"1.1.1.1"

Example output:

{1, 1, 1, 1}
Link to this function parse_ip_byte(string_ip_byte) View Source
parse_ip_byte(String.t()) :: IpWhitelist.ip_byte()

Given a string which contains an integer, convert to an integer (ip_byte) Example input:

"1"

Example output:

1
Link to this function parse_ip_range(string_ip_range) View Source
parse_ip_range(String.t()) :: IpWhitelist.ip_range()

Given a string which contains an ip range, convert to an ip_range Example input:

1.1.1.1-1.1.1.1

Example output:

{{1, 1, 1, 1}, {1, 1, 1, 1}}