lib/shutter/iptables/base.rb in shutter-0.0.1 vs lib/shutter/iptables/base.rb in shutter-0.0.2
- old
+ new
@@ -1,45 +1,49 @@
module Shutter
- module IPTables
- class Base
- def initialize( path )
- @path = path
- file = File.open("#{path}/base.ipt", "r")
- @content = file.read
- end
+ module IPTables
+ class Base
+ def initialize( path )
+ @path = path
+ file = File.open("#{path}/base.ipt", "r")
+ @content = file.read
+ end
- def to_s
- @content
- end
+ def persist_file(os)
+ "/etc/sysconfig/iptables"
+ end
- def generate
- #generate_nat
- generate_filter
- end
+ def to_s
+ @content
+ end
- def generate_filter
- @dmz = Iface.new("#{@path}", :dmz).to_ipt
- @content = @content.gsub(/#\ \[RULES:DMZ\]/, @dmz)
- @bastards = EyePee.new("#{@path}", :deny).to_ipt
- @content = @content.gsub(/#\ \[RULES:BASTARDS\]/, @bastards)
- @public = Port.new("#{@path}", :public).to_ipt
- @content = @content.gsub(/#\ \[RULES:PUBLIC\]/, @public)
- @allow = EyePee.new("#{@path}", :allow).to_ipt
- @content = @content.gsub(/#\ \[RULES:ALLOWIP\]/, @allow)
- @private = Port.new("#{@path}", :private).to_ipt
- @content = @content.gsub(/#\ \[RULES:PRIVATE\]/, @private)
+ def generate
+ #generate_nat
+ generate_filter
+ end
- # Make sure we are restoring what fail2ban has added
- @f2b_chains = Jail.new.fail2ban_chains
- @content = @content.gsub(/#\ \[CHAIN:FAIL2BAN\]/, @f2b_chains)
- @f2b_rules = Jail.new.fail2ban_rules
- @content = @content.gsub(/#\ \[RULES:FAIL2BAN\]/, @f2b_rules)
- @jail = Jail.new.jail_rules
- @content = @content.gsub(/#\ \[RULES:JAIL\]/, @jail)
+ def generate_filter
+ @dmz = Iface.new("#{@path}", :dmz).to_ipt
+ @content = @content.gsub(/#\ \[RULES:DMZ\]/, @dmz)
+ @bastards = EyePee.new("#{@path}", :deny).to_ipt
+ @content = @content.gsub(/#\ \[RULES:BASTARDS\]/, @bastards)
+ @public = Port.new("#{@path}", :public).to_ipt
+ @content = @content.gsub(/#\ \[RULES:PUBLIC\]/, @public)
+ @allow = EyePee.new("#{@path}", :allow).to_ipt
+ @content = @content.gsub(/#\ \[RULES:ALLOWIP\]/, @allow)
+ @private = Port.new("#{@path}", :private).to_ipt
+ @content = @content.gsub(/#\ \[RULES:PRIVATE\]/, @private)
- # Remove the rest of the comments and extra lines
- @content = @content.gsub(/^#.*$/, "")
- @content = @content.gsub(/^$\n/, "")
- end
- end
- end
+ # Make sure we are restoring what fail2ban has added
+ @f2b_chains = Jail.new.fail2ban_chains
+ @content = @content.gsub(/#\ \[CHAIN:FAIL2BAN\]/, @f2b_chains)
+ @f2b_rules = Jail.new.fail2ban_rules
+ @content = @content.gsub(/#\ \[RULES:FAIL2BAN\]/, @f2b_rules)
+ @jail = Jail.new.jail_rules
+ @content = @content.gsub(/#\ \[RULES:JAIL\]/, @jail)
+
+ # Remove the rest of the comments and extra lines
+ @content = @content.gsub(/^#.*$/, "")
+ @content = @content.gsub(/^$\n/, "")
+ end
+ end
+ end
end
\ No newline at end of file