Added iptables counter update script

This commit is contained in:
Priit Tark 2015-05-31 23:28:15 +03:00
parent 80e4fe0529
commit bb6186c33b
6 changed files with 47 additions and 23 deletions

15
lib/iptable.rb Normal file
View file

@ -0,0 +1,15 @@
module Iptable
def counter_update(registrar_code, ip)
counter_proc = "/proc/net/xt_recent/#{registrar_code}"
begin
File.open(counter_proc, 'a') do |f|
f.puts "+#{ip}"
end
rescue Errno::ENOENT => e
logger.error "ERROR: cannot open #{counter_proc}: #{e}"
rescue IOError => e
logger.error "ERROR: cannot write #{ip} to #{counter_proc}: #{e}"
end
end
end