shutter 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shutter/command_line.rb +7 -4
- data/lib/shutter/version.rb +1 -1
- metadata +1 -1
data/lib/shutter/command_line.rb
CHANGED
@@ -18,8 +18,11 @@ module Shutter
|
|
18
18
|
@config_path = path
|
19
19
|
end
|
20
20
|
|
21
|
+
def iptables
|
22
|
+
@iptables ||= Shutter::IPTables::Base.new(@config_path)
|
23
|
+
end
|
24
|
+
|
21
25
|
def execute
|
22
|
-
@iptables = Shutter::IPTables::Base.new(@config_path)
|
23
26
|
options = {}
|
24
27
|
optparse = OptionParser.new do |opts|
|
25
28
|
opts.banner = "Usage: shutter [options]"
|
@@ -84,13 +87,13 @@ module Shutter
|
|
84
87
|
|
85
88
|
def save
|
86
89
|
init
|
87
|
-
@ipt =
|
90
|
+
@ipt = iptables.generate
|
88
91
|
puts @ipt
|
89
92
|
end
|
90
93
|
|
91
94
|
def restore
|
92
95
|
init
|
93
|
-
@ipt =
|
96
|
+
@ipt = iptables.generate
|
94
97
|
IO.popen("#{Shutter::IPTables::IPTABLES_RESTORE}", "r+") do |iptr|
|
95
98
|
iptr.puts @ipt ; iptr.close_write
|
96
99
|
end
|
@@ -98,7 +101,7 @@ module Shutter
|
|
98
101
|
end
|
99
102
|
|
100
103
|
def persist
|
101
|
-
pfile = ENV['SHUTTER_PERSIST_FILE'] ? ENV['SHUTTER_PERSIST_FILE'] :
|
104
|
+
pfile = ENV['SHUTTER_PERSIST_FILE'] ? ENV['SHUTTER_PERSIST_FILE'] : iptables.persist_file(@os)
|
102
105
|
File.open(pfile, "w") do |f|
|
103
106
|
f.write(@ipt)
|
104
107
|
end
|
data/lib/shutter/version.rb
CHANGED