Class: Mt::Wall::Model::AddressObject

Inherits:
Data
  • Object
show all
Defined in:
lib/mt/wall/model/address_object.rb

Overview

A named firewall object: a label bound to one or more IP addresses or CIDR subnets. Compiles to entries in a RouterOS ‘/ip firewall address-list`. The same address may belong to many objects (one IP -> many list memberships), which is native to address-lists.

ADDRESS FAMILY (IPv4 vs IPv6) is INFERRED per address via the stdlib ‘IPAddr` — there are no separate v4/v6 verbs and a single object MAY hold a mix of families. The Compiler partitions the addresses by family so that IPv4 entries land in `/ip/firewall/address-list` and IPv6 entries in `/ipv6/firewall/address-list` (see Compiler / DesiredState).

VALIDATION (fail-fast at the DSL/model boundary): ‘name` must match the strict charset `A+z`; every entry in `addresses` must be a valid single address, a CIDR subnet, OR an IP RANGE (`10.0.0.1-10.0.0.10`, both endpoints the same family) — each form parses via `IPAddr` (this also neutralizes .rsc / JSON injection). FQDN address-list entries are OUT OF SCOPE for v1 (future). An object with NO addresses is an error.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, addresses: [], comment: nil) ⇒ AddressObject

Returns a new instance of AddressObject.



29
30
31
# File 'lib/mt/wall/model/address_object.rb', line 29

def initialize(name:, addresses: [], comment: nil)
  super(name: name, addresses: Array(addresses), comment: comment)
end

Instance Attribute Details

#addressesObject (readonly)

Returns the value of attribute addresses

Returns:

  • (Object)

    the current value of addresses



28
29
30
31
32
# File 'lib/mt/wall/model/address_object.rb', line 28

AddressObject = Data.define(:name, :addresses, :comment) do
  def initialize(name:, addresses: [], comment: nil)
    super(name: name, addresses: Array(addresses), comment: comment)
  end
end

#commentObject (readonly)

Returns the value of attribute comment

Returns:

  • (Object)

    the current value of comment



28
29
30
31
32
# File 'lib/mt/wall/model/address_object.rb', line 28

AddressObject = Data.define(:name, :addresses, :comment) do
  def initialize(name:, addresses: [], comment: nil)
    super(name: name, addresses: Array(addresses), comment: comment)
  end
end

#nameObject (readonly)

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



28
29
30
31
32
# File 'lib/mt/wall/model/address_object.rb', line 28

AddressObject = Data.define(:name, :addresses, :comment) do
  def initialize(name:, addresses: [], comment: nil)
    super(name: name, addresses: Array(addresses), comment: comment)
  end
end