Class: Spior::Ipv6
- Inherits:
-
Object
- Object
- Spior::Ipv6
- Defined in:
- lib/spior/ipv6.rb
Overview
Block or Allow ipv6 traffic with sysctl
Instance Method Summary collapse
- #allow ⇒ Object
- #block ⇒ Object
- #block_persist ⇒ Object
-
#initialize ⇒ Ipv6
constructor
A new instance of Ipv6.
Constructor Details
#initialize ⇒ Ipv6
Returns a new instance of Ipv6.
9 10 11 12 13 14 15 |
# File 'lib/spior/ipv6.rb', line 9 def initialize @dest = '/etc/sysctl.d/40-ipv6.conf' @cmdline_path = '/proc/cmdline' @opened = false collect_cmdline_args gen_flags end |
Instance Method Details
#allow ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/spior/ipv6.rb', line 17 def allow return if check_ipv6_disabled? @flags.each { |f| Helpers.cmd("sysctl -q -w '#{f}=0'") } Msg.p 'ipv6 allowed' Helpers.cmd("rm #{@dest}") if File.exist? @dest end |
#block ⇒ Object
25 26 27 28 29 30 |
# File 'lib/spior/ipv6.rb', line 25 def block return if check_ipv6_disabled? @flags.each { |f| Helpers.cmd("sysctl -q -w '#{f}=1'") } Msg.p 'ipv6 blocked' end |
#block_persist ⇒ Object
32 33 34 35 36 37 38 39 40 |
# File 'lib/spior/ipv6.rb', line 32 def block_persist return if check_ipv6_disabled? Auth.new.mkdir '/etc/sysctl.d' myflags = [] @flags.each { |f| myflags << "#{f}=1" } File.write('/tmp/flags.conf', myflags.join("\n")) Helpers.cmd("cp /tmp/flags.conf #{@dest}") end |