Class: IP::Rule
- Inherits:
-
Object
- Object
- IP::Rule
- Defined in:
- lib/iptable/ip.rb
Instance Attribute Summary collapse
-
#chain ⇒ Object
Returns the value of attribute chain.
-
#packets ⇒ Object
readonly
Returns the value of attribute packets.
-
#target ⇒ Object
Returns the value of attribute target.
Instance Method Summary collapse
-
#initialize(options) ⇒ Rule
constructor
A new instance of Rule.
- #save ⇒ Object
Constructor Details
#initialize(options) ⇒ Rule
Returns a new instance of Rule.
116 117 118 119 120 121 122 123 |
# File 'lib/iptable/ip.rb', line 116 def initialize() @chain = [:chain] raise "Rule needs a chain" unless @chain @packets = [:packets].to_i @target = nil @dport = [:dport] @protocol = [:protocol] || "all" end |
Instance Attribute Details
#chain ⇒ Object
Returns the value of attribute chain.
113 114 115 |
# File 'lib/iptable/ip.rb', line 113 def chain @chain end |
#packets ⇒ Object (readonly)
Returns the value of attribute packets.
114 115 116 |
# File 'lib/iptable/ip.rb', line 114 def packets @packets end |
#target ⇒ Object
Returns the value of attribute target.
113 114 115 |
# File 'lib/iptable/ip.rb', line 113 def target @target end |
Instance Method Details
#save ⇒ Object
125 126 127 128 129 |
# File 'lib/iptable/ip.rb', line 125 def save IO.popen("/sbin/iptables -A #{@chain.name} -p #{@protocol} --dport #{@dport}") do |output| puts output.read end end |