Class ACL
In: lib/drb/acl.rb
Parent: Object

Methods

Classes and Modules

Class ACL::ACLEntry
Class ACL::ACLList

Constants

VERSION = ["2.0.0"]
DENY_ALLOW = 0
ALLOW_DENY = 1

Public Class methods

[Source]

    # File lib/drb/acl.rb, line 82
82:   def initialize(list=nil, order = DENY_ALLOW)
83:     @order = order
84:     @deny = ACLList.new
85:     @allow = ACLList.new
86:     install_list(list) if list
87:   end

Public Instance methods

[Source]

     # File lib/drb/acl.rb, line 95
 95:   def allow_addr?(addr)
 96:     case @order
 97:     when DENY_ALLOW
 98:       return true if @allow.match(addr)
 99:       return false if @deny.match(addr)
100:       return true
101:     when ALLOW_DENY
102:       return false if @deny.match(addr)
103:       return true if @allow.match(addr)
104:       return false
105:     else
106:       false
107:     end
108:   end

[Source]

    # File lib/drb/acl.rb, line 90
90:   def allow_socket?(soc)
91:     allow_addr?(soc.peeraddr)
92:   end

[Source]

     # File lib/drb/acl.rb, line 111
111:   def install_list(list)
112:     i = 0
113:     while i < list.size
114:       permission, domain = list.slice(i,2)
115:       case permission.downcase
116:       when 'allow'
117:         @allow.add(domain)
118:       when 'deny'
119:         @deny.add(domain)
120:       else
121:         raise "Invalid ACL entry #{list.to_s}"
122:       end
123:       i += 2
124:     end
125:   end

[Validate]