Module: Spior::Service

Defined in:
lib/spior/service.rb,
lib/spior/service/stop.rb,
lib/spior/service/start.rb,
lib/spior/service/enable.rb,
lib/spior/service/restart.rb

Overview

Interact with Spior::Tor and Spior::Iptables

Defined Under Namespace

Classes: Enable

Class Method Summary collapse

Class Method Details

.restartObject



10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/spior/service/restart.rb', line 10

def restart
  case Nomansland.init?
  when :systemd
    Helpers.cmd('systemctl restart tor')
  when :openrc
    Helpers.cmd('/etc/init.d/tor restart')
  when :runit
    Helpers.cmd('sv restart tor')
  else
    puts 'No init found (systemd, openrc, runit)...'
  end
  Msg.p 'Tor restarting, ip changed.'
end

.startObject

Service.start should start Tor if not alrealy running And start to redirect the local traffic with Iptables



10
11
12
13
14
# File 'lib/spior/service/start.rb', line 10

def start
  Tor::Start.new
  Iptables::Tor.new.run!
  Ipv6.new.block
end

.stop(clean: true) ⇒ Object



8
9
10
11
12
# File 'lib/spior/service/stop.rb', line 8

def stop(clean: true)
  Tor::Stop.new
  Iptables::Rules.new.restore if clean
  Ipv6.new.allow if clean
end