Class: Netfilter::EbTables

Inherits:
Tool
  • Object
show all
Defined in:
lib/netfilter/eb_tables.rb

Instance Attribute Summary

Attributes inherited from Tool

#namespace, #tables

Class Method Summary collapse

Methods inherited from Tool

#commands, delete_chain, #down, executable, #executable, execute, #export, import, #initialize, #pp, #table, #up

Constructor Details

This class inherits a constructor from Netfilter::Tool

Class Method Details

.parseObject



4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/netfilter/eb_tables.rb', line 4

def self.parse
  {}.tap do |data|
    string = execute("#{executable} --list").strip << "\n"
    string.split(/^Bridge table:\s+/).select{ |s| s != "" }.each do |string|
      table, string = string.match(/(.+?)\n\n(.*)/m).to_a[1..-1]
      data[table] = {}
      string.split(/^Bridge chain:\s+/).select{ |s| s != "" }.each do |string|
        chain, string = string.match(/(.+?),.+?\n(.*)/m).to_a[1..-1]
        data[table][chain] = string.split("\n").map(&:strip)
      end
    end
  end
end