Software /
code /
prosody-modules
Comparison
mod_lastlog/mod_lastlog.lua @ 616:884ae37d76bf
mod_lastlog: Add option to also log the users IP address.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 24 Feb 2012 15:38:14 +0100 |
parent | 615:4134d0e25242 |
child | 1039:3f91f17ddaca |
comparison
equal
deleted
inserted
replaced
615:4134d0e25242 | 616:884ae37d76bf |
---|---|
1 local datamanager = require "util.datamanager"; | 1 local datamanager = require "util.datamanager"; |
2 local time = os.time; | 2 local time = os.time; |
3 local log_ip = module:get_option_boolean("lastlog_ip_address", false); | |
3 | 4 |
4 module:hook("authentication-success", function(event) | 5 module:hook("authentication-success", function(event) |
5 local session = event.session; | 6 local session = event.session; |
6 if session.username then | 7 if session.username then |
7 datamanager.store(session.username, session.host, "lastlog", { | 8 datamanager.store(session.username, session.host, "lastlog", { |
8 timestamp = time(), | 9 timestamp = time(), |
10 ip = log_ip and session.ip or nil, | |
9 }); | 11 }); |
10 end | 12 end |
11 end); | 13 end); |