Class: Puffy::RuleFactory
- Inherits:
-
Object
- Object
- Puffy::RuleFactory
- Defined in:
- lib/puffy/rule_factory.rb
Overview
Puffy::Rule factory
Instance Method Summary collapse
-
#build(options = {}) ⇒ Array<Puffy::Rule>
Return an Array of Puffy::Rule for the provided
options. -
#initialize ⇒ RuleFactory
constructor
Initialize a Puffy::Rule factory.
-
#ipv4 ⇒ Object
Limit the scope of a set of rules to IPv4 only.
-
#ipv6 ⇒ Object
Limit the scope of a set of rules to IPv6 only.
Constructor Details
#initialize ⇒ RuleFactory
Initialize a Puffy::Rule factory.
7 8 9 10 11 |
# File 'lib/puffy/rule_factory.rb', line 7 def initialize @af = nil @resolver = Resolver.instance load_services end |
Instance Method Details
#build(options = {}) ⇒ Array<Puffy::Rule>
Return an Array of Puffy::Rule for the provided options.
34 35 36 37 38 39 40 41 |
# File 'lib/puffy/rule_factory.rb', line 34 def build( = {}) return [] if == {} = { action: nil, return: false, dir: nil, af: nil, proto: nil, on: nil, from: { host: nil, port: nil }, to: { host: nil, port: nil }, nat_to: nil, rdr_to: { host: nil, port: nil } }.merge() = resolv_hostnames_and_ports() instanciate_rules() end |
#ipv4 ⇒ Object
Limit the scope of a set of rules to IPv4 only.
14 15 16 17 18 19 20 |
# File 'lib/puffy/rule_factory.rb', line 14 def ipv4 raise 'Address familly already scopped' if @af @af = :inet yield @af = nil end |
#ipv6 ⇒ Object
Limit the scope of a set of rules to IPv6 only.
23 24 25 26 27 28 29 |
# File 'lib/puffy/rule_factory.rb', line 23 def ipv6 raise 'Address familly already scopped' if @af @af = :inet6 yield @af = nil end |