module TShield::Sessions
Manage sessions
Start and stop session for ip
Public Class Methods
append(ip, name)
click to toggle source
# File lib/tshield/sessions.rb, line 31 def self.append(ip, name) TShield.logger.info("appeding session #{name} for ip #{normalize_ip(ip)}") current_session = sessions[normalize_ip(ip)] raise AppendSessionWithoutMainSessionError, "not found main session for #{ip}" unless current_session current_session[:secondary_sessions] << name current_session end
current(ip)
click to toggle source
# File lib/tshield/sessions.rb, line 26 def self.current(ip) TShield.logger.info("fetching session for ip #{normalize_ip(ip)}") sessions[normalize_ip(ip)] end
normalize_ip(ip)
click to toggle source
# File lib/tshield/sessions.rb, line 45 def self.normalize_ip(ip) ip == '::1' ? '127.0.0.1' : ip end
sessions()
click to toggle source
# File lib/tshield/sessions.rb, line 41 def self.sessions @sessions ||= {} end
start(ip, name)
click to toggle source
# File lib/tshield/sessions.rb, line 12 def self.start(ip, name) TShield.logger.info("starting session #{name} for ip #{normalize_ip(ip)}") sessions[normalize_ip(ip)] = { name: name, counter: TShield::Counter.new, secondary_sessions: [] } end
stop(ip)
click to toggle source
# File lib/tshield/sessions.rb, line 21 def self.stop(ip) TShield.logger.info("stoping session for ip #{normalize_ip(ip)}") sessions[normalize_ip(ip)] = nil end