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 84
84:   def initialize(list=nil, order = DENY_ALLOW)
85:     @order = order
86:     @deny = ACLList.new
87:     @allow = ACLList.new
88:     install_list(list) if list
89:   end

Public Instance methods

[Source]

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

[Source]

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

[Source]

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

[Validate]