Class: Iptables

Inherits:
Object
  • Object
show all
Defined in:
lib/iptables.rb

Overview

This class encodes and decodes iptables style -save and -restore formats

Version:

  • 1.0.0

Defined Under Namespace

Classes: Decoder, IptablesException, NoTable, UnparseableLine, UnparseableSplit

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.decode(text, opts = {}) ⇒ Hash

Takes the output for iptables-save returning a hash

Examples:

Decode iptables-save output

Iptables.decode(`iptables-save`)

Parameters:

  • text (String)

    the raw output of iptables-save

  • opts (Hash) (defaults to: {})

    options for the decoder

Options Hash (opts):

  • :debug (Bool)

    If true, turns on debugging output

  • :iptables_compatibilty (String)

    version of iptables to be compatible with. Since some versions differ wildly, this might be necessary.

Returns:

  • (Hash)

    returns a hash containing the parsed rules

See Also:



20
21
22
23
# File 'lib/iptables.rb', line 20

def self.decode(text, opts = {})
  decoder = Decoder.new(opts)
  decoder.decode(text)
end