Class: OnetableTerminator::Core

Inherits:
Object
  • Object
show all
Defined in:
lib/onetable_terminator/core.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dry_run = false) ⇒ Core



5
6
7
8
# File 'lib/onetable_terminator/core.rb', line 5

def initialize(dry_run = false)
  @exec = OnetableTerminator::Iptables::Exec.new dry_run
  @rules_handler = OnetableTerminator::Iptables::RulesHandler.new
end

Instance Attribute Details

#execObject (readonly)

Returns the value of attribute exec.



3
4
5
# File 'lib/onetable_terminator/core.rb', line 3

def exec
  @exec
end

#rules_handlerObject (readonly)

Returns the value of attribute rules_handler.



3
4
5
# File 'lib/onetable_terminator/core.rb', line 3

def rules_handler
  @rules_handler
end

Instance Method Details

#runObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/onetable_terminator/core.rb', line 10

def run
  rules = retrieve_redundant_rules

  if rules.empty?
    logger.debug 'Found no redundant rules, nothing to delete'
    return
  end

  log_redundant_rules rules
  delete_redundant_rules rules
end