Class: Dizby::Access::ControlList
- Inherits:
-
Object
- Object
- Dizby::Access::ControlList
- Defined in:
- lib/dizby/access/control_list.rb
Instance Method Summary collapse
- #allow_addr?(addr) ⇒ Boolean
- #allow_deny?(addr) ⇒ Boolean private
- #allow_socket?(soc) ⇒ Boolean
- #deny_allow?(addr) ⇒ Boolean private
-
#initialize(order = :deny_allow) ⇒ ControlList
constructor
:allow_deny if denied, deny else if allowed, allow else, deny.
- #install_list(list)
Constructor Details
#initialize(order = :deny_allow) ⇒ ControlList
:allow_deny if denied, deny else if allowed, allow else, deny
24 25 26 27 28 |
# File 'lib/dizby/access/control_list.rb', line 24 def initialize(order = :deny_allow) @order = order @deny = List.new @allow = List.new end |
Instance Method Details
#allow_addr?(addr) ⇒ Boolean
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/dizby/access/control_list.rb', line 34 def allow_addr?(addr) case @order when :deny_allow deny_allow?(addr) when :allow_deny allow_deny?(addr) else false end end |
#allow_deny?(addr) ⇒ Boolean (private)
67 68 69 70 71 |
# File 'lib/dizby/access/control_list.rb', line 67 def allow_deny?(addr) return false if @deny.matches?(addr) return true if @allow.matches?(addr) false end |
#allow_socket?(soc) ⇒ Boolean
30 31 32 |
# File 'lib/dizby/access/control_list.rb', line 30 def allow_socket?(soc) allow_addr?(soc.peeraddr) end |
#deny_allow?(addr) ⇒ Boolean (private)
61 62 63 64 65 |
# File 'lib/dizby/access/control_list.rb', line 61 def deny_allow?(addr) return true if @allow.matches?(addr) return false if @deny.matches?(addr) true end |
#install_list(list)
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/dizby/access/control_list.rb', line 45 def install_list(list) Hash[*list].each do |, domain| domain = Entry.new(domain) case .downcase when 'allow' @allow.push(domain) when 'deny' @deny.push(domain) else fail ArgumentError, "Invalid ACL entry #{list}" end end end |