Class: Mt::Wall::Model::Rule
- Inherits:
-
Data
- Object
- Data
- Mt::Wall::Model::Rule
- Defined in:
- lib/mt/wall/model/rule.rb
Overview
An access grant between two objects/groups (Layer A — abstract, device-agnostic). Compiles to one or more ‘/ip firewall filter` rules using `src-address-list` / `dst-address-list` (and protocol/dst-port when a service is given).
DUAL-STACK: because endpoints may hold a mix of IPv4 and IPv6 addresses, ONE abstract grant compiles to a v4 filter rule for the endpoints’ v4 members AND a v6 filter rule for their v6 members. A family with no overlap simply yields no rule for THAT family. But a grant that yields NO rule in EITHER family (e.g. a v4-only source paired with a v6-only destination) FAILS FAST with ConfigurationError in the Compiler — it never silently produces nothing. Family selection happens entirely in the Compiler; the grant itself never names a family.
RULE IDENTITY: the concrete rule this grant compiles to is tagged with a deterministic, CONTENT-ONLY ‘mt-wall:<stable-hash>` identity in its RouterOS `comment` (chain + normalized match + action + src/dst list references; position EXCLUDED — see Model::FilterRule and the Compiler). Diff/Plan match desired vs. current rules by that tag, NOT by the device-assigned `.id`; ordering is handled separately by the Plan (:move + Operation#position). `comment` below is the OPERATOR’s human-readable note, kept distinct from (and merged alongside) the machine identity tag at compile time.
RULE-LEVEL ATTRIBUTES (NOT match conditions): ‘log` / `log_prefix` and `disabled` are excluded from the content-only identity tag, exactly as on Model::FilterRule — toggling them is an in-place :update, not a churn.
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#comment ⇒ Object
readonly
Returns the value of attribute comment.
-
#destination ⇒ Object
readonly
Returns the value of attribute destination.
-
#disabled ⇒ Object
readonly
Returns the value of attribute disabled.
-
#log ⇒ Object
readonly
Returns the value of attribute log.
-
#log_prefix ⇒ Object
readonly
Returns the value of attribute log_prefix.
-
#service ⇒ Object
readonly
Returns the value of attribute service.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
Instance Method Summary collapse
-
#action(value) ⇒ Object
readonly
:accept or :drop.
-
#disabled(value) ⇒ Object
readonly
keep the grant but inactive (disabled=yes).
-
#initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) ⇒ Rule
constructor
A new instance of Rule.
-
#log(value) ⇒ Object
readonly
log matched packets (RouterOS log=yes).
Constructor Details
#initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) ⇒ Rule
Returns a new instance of Rule.
43 44 45 46 |
# File 'lib/mt/wall/model/rule.rb', line 43 def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end |
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action
42 43 44 |
# File 'lib/mt/wall/model/rule.rb', line 42 def action @action end |
#comment ⇒ Object (readonly)
Returns the value of attribute comment
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |
#destination ⇒ Object (readonly)
Returns the value of attribute destination
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |
#disabled ⇒ Object (readonly)
Returns the value of attribute disabled
42 43 44 |
# File 'lib/mt/wall/model/rule.rb', line 42 def disabled @disabled end |
#log ⇒ Object (readonly)
Returns the value of attribute log
42 43 44 |
# File 'lib/mt/wall/model/rule.rb', line 42 def log @log end |
#log_prefix ⇒ Object (readonly)
Returns the value of attribute log_prefix
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |
#service ⇒ Object (readonly)
Returns the value of attribute service
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |
#source ⇒ Object (readonly)
Returns the value of attribute source
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |
Instance Method Details
#action=(value) ⇒ Object (readonly)
:accept or :drop
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |
#disabled=(value) ⇒ Object (readonly)
keep the grant but inactive (disabled=yes)
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |
#log=(value) ⇒ Object (readonly)
log matched packets (RouterOS log=yes)
42 43 44 45 46 47 |
# File 'lib/mt/wall/model/rule.rb', line 42 Rule = Data.define(:source, :destination, :service, :action, :comment, :log, :log_prefix, :disabled) do def initialize(source:, destination:, action:, service: nil, comment: nil, log: false, log_prefix: nil, disabled: false) super end end |