Class: Dcmgr::VNet::Netfilter::IptablesRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/dcmgr/vnet/netfilter/iptables_rule.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(table = nil, chain = nil, protocol = nil, bound = nil, rule = nil) ⇒ IptablesRule

Returns a new instance of IptablesRule.

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
23
# File 'lib/dcmgr/vnet/netfilter/iptables_rule.rb', line 15

def initialize(table = nil, chain = nil, protocol = nil, bound = nil, rule = nil)
  super()
  raise ArgumentError, "table does not exist: #{table}" unless IptablesChain.pre_made.keys.member?(table)
  self.table = table
  self.chain = chain
  self.protocol = protocol
  self.bound = bound
  self.rule = rule
end

Instance Attribute Details

#boundObject

Should be either :incoming or :outgoing



12
13
14
# File 'lib/dcmgr/vnet/netfilter/iptables_rule.rb', line 12

def bound
  @bound
end

#chainObject

Returns the value of attribute chain.



9
10
11
# File 'lib/dcmgr/vnet/netfilter/iptables_rule.rb', line 9

def chain
  @chain
end

#protocolObject

Returns the value of attribute protocol.



13
14
15
# File 'lib/dcmgr/vnet/netfilter/iptables_rule.rb', line 13

def protocol
  @protocol
end

#ruleObject

Returns the value of attribute rule.



10
11
12
# File 'lib/dcmgr/vnet/netfilter/iptables_rule.rb', line 10

def rule
  @rule
end

#tableObject

Returns the value of attribute table.



8
9
10
# File 'lib/dcmgr/vnet/netfilter/iptables_rule.rb', line 8

def table
  @table
end

Class Method Details

.protocolsObject

Getter for the protocols iptables supports



34
35
36
37
38
39
40
# File 'lib/dcmgr/vnet/netfilter/iptables_rule.rb', line 34

def self.protocols
  {
    'tcp'  => 'tcp',
    'udp'  => 'udp',
    'icmp' => 'icmp',
  }
end