Class: Gitlab::UrlBlockers::IpAllowlistEntry

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/url_blockers/ip_allowlist_entry.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#ipObject (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

#portObject (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

Returns:

  • (Boolean)

14
15
16
17
18
19
# File 'lib/gitlab/url_blockers/ip_allowlist_entry.rb', line 14

def match?(requested_ip, requested_port = nil)
  return false unless ip.include?(requested_ip)
  return true if port.nil?

  port == requested_port
end