Extended maintenance of Ruby versions 1.8.7 and 1.9.2 ended on July 31, 2014. Read more

In Files

  • drb/acl.rb

Parent

Methods

ACL::ACLEntry

Public Class Methods

new(str) click to toggle source
 
               # File drb/acl.rb, line 13
def initialize(str)
  if str == '*' or str == 'all'
    @pat = [:all]
  elsif str.include?('*')
    @pat = [:name, dot_pat(str)]
  else
    begin
      @pat = [:ip, IPAddr.new(str)]
    rescue ArgumentError
      @pat = [:name, dot_pat(str)]
    end
  end
end
            

Public Instance Methods

match(addr) click to toggle source
 
               # File drb/acl.rb, line 42
def match(addr)
  case @pat[0]
  when :all
    true
  when :ip
    begin
      ipaddr = IPAddr.new(addr[3])
      ipaddr = ipaddr.ipv4_mapped if @pat[1].ipv6? && ipaddr.ipv4?
    rescue ArgumentError
      return false
    end
    (@pat[1].include?(ipaddr)) ? true : false
  when :name
    (@pat[1] =~ addr[2]) ? true : false
  else
    false
  end
end