class PacketThief::Impl::Netfilter::IPTablesRule

Adds IPTables specific details to a Redirectrule.

Attributes

chain[RW]
table[RW]

Public Class Methods

new(handler, table, chain) click to toggle source
# File lib/packetthief/impl/netfilter.rb, line 62
def initialize(handler, table, chain)
  super(handler)
  @table = table
  @chain = chain
end

Public Instance Methods

to_netfilter_command() click to toggle source
# File lib/packetthief/impl/netfilter.rb, line 68
def to_netfilter_command
  args = []

  if self.rulespec
    args << '-p' << self.rulespec[:protocol].to_s if self.rulespec.has_key? :protocol
    args << '--destination-port' << self.rulespec[:dest_port].to_s if self.rulespec.has_key? :dest_port
    args << '--in-interface' << self.rulespec[:in_interface].to_s if self.rulespec.has_key? :in_interface
  end

  if self.redirectspec
    args << '-j' << 'REDIRECT'
    args << '--to-ports' << self.redirectspec[:to_ports].to_s if self.redirectspec.has_key? :to_ports
  end

  args
end