Class: Gitlab::UrlBlockers::IpAllowlistEntry
- Inherits:
-
Object
- Object
- Gitlab::UrlBlockers::IpAllowlistEntry
- Defined in:
- lib/gitlab/url_blockers/ip_allowlist_entry.rb
Instance Attribute Summary collapse
-
#ip ⇒ Object
readonly
Returns the value of attribute ip.
-
#port ⇒ Object
readonly
Returns the value of attribute port.
Instance Method Summary collapse
-
#initialize(ip, port: nil) ⇒ IpAllowlistEntry
constructor
Argument ip should be an IPAddr object.
- #match?(requested_ip, requested_port = nil) ⇒ Boolean
Constructor Details
#initialize(ip, port: nil) ⇒ IpAllowlistEntry
Argument ip should be an IPAddr object
9 10 11 12 |
# File 'lib/gitlab/url_blockers/ip_allowlist_entry.rb', line 9 def initialize(ip, port: nil) @ip = ip @port = port end |
Instance Attribute Details
#ip ⇒ Object (readonly)
Returns the value of attribute ip.
6 7 8 |
# File 'lib/gitlab/url_blockers/ip_allowlist_entry.rb', line 6 def ip @ip end |
#port ⇒ Object (readonly)
Returns the value of attribute port.
6 7 8 |
# File 'lib/gitlab/url_blockers/ip_allowlist_entry.rb', line 6 def port @port end |
Instance Method Details
#match?(requested_ip, requested_port = nil) ⇒ Boolean
14 15 16 17 18 19 20 21 |
# File 'lib/gitlab/url_blockers/ip_allowlist_entry.rb', line 14 def match?(requested_ip, requested_port = nil) requested_ip = IPAddr.new(requested_ip) if requested_ip.is_a?(String) return false unless ip_include?(requested_ip) return true if port.nil? port == requested_port end |