Class: Puffy::Formatters::Iptables::Ruleset

Inherits:
Base::Ruleset show all
Defined in:
lib/puffy/formatters/iptables.rb

Overview

Iptables implementation of a Puffy Ruleset formatter.

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base::Ruleset

#emit_header, #filename_fragment, #initialize

Constructor Details

This class inherits a constructor from Puffy::Formatters::Base::Ruleset

Class Method Details

.known_conntrack_helpersObject

:nodoc:



20
21
22
23
24
25
26
27
28
# File 'lib/puffy/formatters/iptables.rb', line 20

def self.known_conntrack_helpers
  {
    21   => 'ftp',
    69   => 'tftp',
    194  => 'irc',
    6566 => 'sane',
    5060 => 'sip',
  }
end

Instance Method Details

#emit_ruleset(rules, policy = :block) ⇒ Object

Returns a Iptables String representation of the provided rules Array of Puffy::Rule with the policy policy.



31
32
33
34
35
36
37
38
39
# File 'lib/puffy/formatters/iptables.rb', line 31

def emit_ruleset(rules, policy = :block)
  parts = []
  parts << emit_header
  parts << raw_ruleset(raw_rules(rules))
  parts << nat_ruleset(nat_rules(rules))
  parts << filter_ruleset(filter_rules(rules), policy)
  ruleset = parts.flatten.compact.join("\n")
  "#{ruleset}\n"
end