Class: ACL::ACLEntry

Class | ACL::ACLEntry
In: | drb/acl.rb
Parent: | Object

### Methods

match new

### Public Class methods

new(str)

[Source]

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

### Public Instance methods

match(addr)

[Source]

    # File drb/acl.rb, line 40
        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

[Validate]