Class: Spior::Iptables::Rules

Inherits:
Object
  • Object
show all
Defined in:
lib/spior/iptables/rules.rb

Overview

Iptables::Rules, used to save or restore iptables rules

Instance Method Summary collapse

Constructor Details

#initializeRules

Returns a new instance of Rules.



11
12
13
14
# File 'lib/spior/iptables/rules.rb', line 11

def initialize
  @tmp_iptables_rules = Tempfile.new('iptables_rules')
  @save_path = search_iptables_config
end

Instance Method Details

#restoreObject



22
23
24
25
26
27
# File 'lib/spior/iptables/rules.rb', line 22

def restore
  return if restoring_older_rules

  Msg.p 'Adding clearnet navigation...'
  Iptables::Default.new.run!
end

#saveObject



16
17
18
19
20
# File 'lib/spior/iptables/rules.rb', line 16

def save
  Helpers.cmd("iptables-save > #{@tmp_iptables_rules.path}")
  Helpers.mv(@tmp_iptables_rules.path, @save_path)
  Msg.p "Iptables rules saved at #{@save_path}"
end