Class: Conpar::Directive::AccessList::Extended

Inherits:
Base
  • Object
show all
Defined in:
lib/conpar/directive/access_list/extended.rb

Overview

Constant Summary collapse

SIGNATURE =

(0.1.4): “extended” should be followed by “permit” or “deny” (0.2.2): “extended” optional (legacy syntax support)

%r/^
  (access-list)\s+
  (#{NAME})\s+
  (line\s+(\d+))?\s*
  (extended)?\s*
  (permit|deny)
/x

Constants inherited from Base

Base::NAME

Instance Attribute Summary

Attributes inherited from Base

#content, #ilk, #line_number, #line_span, #match_data, #rule, #sub_ilk

Instance Method Summary collapse

Methods inherited from Base

#to_s

Constructor Details

#initialize(content = "", options = {}) ⇒ Extended

Returns a new instance of Extended


17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/conpar/directive/access_list/extended.rb', line 17

def initialize(content="", options={})
  super

  @sub_ilk = "extended"

  # host (ipaddr) mask (ipaddr)
  ipaddr_regex = %r/
    (?<octet>1?[0-9]{1,2}|2([0-4][0-9]|5[0-5]))\.\k<octet>\.\k<octet>\.\k<octet>
  /x

  # access-list access_list_name [line line_number] [extended]
  # {deny | permit} protocol_argument source_address_argument dest_address_argument
  # [log [[level] [interval secs] | disable | default]]
  # [inactive | time-range time_range_name]
  parse_regex = %r/^
    (access-list)\s+                 # Directive Signature
    (?<name>#{NAME})\s+              # ACL Name
    (line\s+(?<line>\d+))?\s*        # (optional) line number
    (?<type>extended)?\s*            # (optional) ACL type (legacy syntax support)
    (?<permission>(permit|deny))?\s* # permit or deny
    (?<protocol>\w+)\s*              # Protocol Argument
    (?<rule>.+)                      # Everything else on line
  $/x
  @match_data = parse_regex.match(@content)

  self
end