struct
Amber::Support::TrustedProxyNetwork
- Amber::Support::TrustedProxyNetwork
- Struct
- Value
- Object
Overview
One entry of the server.trusted_proxies setting: a single IP address or
a CIDR block, such as "127.0.0.1", "10.0.0.0/8", or "fd00::/8".
Addresses are compared as 128-bit values. IPv4 addresses and blocks are
mapped into ::ffff:0:0/96, so a peer that reaches a dual-stack listener
as ::ffff:127.0.0.1 still matches the block 127.0.0.0/8.
network = Amber::Support::TrustedProxyNetwork.parse("10.0.0.0/8")
network.includes?(Socket::IPAddress.new("10.1.2.3", 0)) # => true
network.includes?(Socket::IPAddress.new("192.168.0.1", 0)) # => false
Defined in:
amber/support/trusted_proxy_network.crConstructors
-
.parse(notation : String) : self
Parses notation into a network, raising
Amber::Exceptions::ConfigurationErrorwhen it is not an IP address or CIDR block.
Class Method Summary
-
.parse?(notation : String) : self | Nil
Parses notation into a network, returning
nilwhen it is not an IP address or CIDR block. -
.read_only_slice(list_of_networks : Array(TrustedProxyNetwork)) : Slice(TrustedProxyNetwork)
Copies list_of_networks into a slice that raises on any write.
Instance Method Summary
-
#covers_every_address? : Bool
Returns
truewhen this network covers every IPv4 address or every IPv6 address, as0.0.0.0/0,::/0and::/80do. -
#includes?(address : Socket::Address) : Bool
Returns
truewhen address falls inside this network. -
#notation : String
The entry as it was written in the configuration.
Constructor Detail
Parses notation into a network, raising
Amber::Exceptions::ConfigurationError when it is not an IP address or
CIDR block.
Class Method Detail
Parses notation into a network, returning nil when it is not an IP
address or CIDR block.
Copies list_of_networks into a slice that raises on any write.
Instance Method Detail
Returns true when this network covers every IPv4 address or every
IPv6 address, as 0.0.0.0/0, ::/0 and ::/80 do. Such an entry
would make every client a trusted proxy.
Returns true when address falls inside this network. Peers that are
not IP sockets (for example UNIX sockets) never match.