Module: Datadog::Core::Utils::Network
- Defined in:
- lib/datadog/core/utils/network.rb
Overview
Common Network utility functions.
Constant Summary collapse
- DEFAULT_IP_HEADERS_NAMES =
%w[ x-forwarded-for x-real-ip true-client-ip x-client-ip x-forwarded forwarded-for x-cluster-client-ip fastly-client-ip cf-connecting-ip cf-connecting-ipv6 ].freeze
Class Method Summary collapse
- .stripped_ip(ip) ⇒ String?
-
.stripped_ip_from_request_headers(headers, ip_headers_to_check: DEFAULT_IP_HEADERS_NAMES) ⇒ String?
Returns a client IP associated with the request if it was retrieved successfully.
Class Method Details
.stripped_ip(ip) ⇒ String?
41 42 43 44 |
# File 'lib/datadog/core/utils/network.rb', line 41 def stripped_ip(ip) ip = ip_to_ipaddr(ip) ip ? ip.to_s : nil end |
.stripped_ip_from_request_headers(headers, ip_headers_to_check: DEFAULT_IP_HEADERS_NAMES) ⇒ String?
Returns a client IP associated with the request if it was
retrieved successfully.
32 33 34 35 36 |
# File 'lib/datadog/core/utils/network.rb', line 32 def stripped_ip_from_request_headers(headers, ip_headers_to_check: DEFAULT_IP_HEADERS_NAMES) ip = ip_header(headers, ip_headers_to_check) ip ? ip.to_s : nil end |