Software /
code /
prosody
Annotate
plugins/mod_uptime.lua @ 1657:1fe566011e2b
Moving realm at the beginning of the digest-md5 message send by the server.
author | Tobias Markmann <tm@ayena.de> |
---|---|
date | Sun, 09 Aug 2009 21:19:03 +0200 |
parent | 1524:a89fec6d76d2 |
child | 2015:2140c994671e |
rev | line source |
---|---|
1523
841d61be198f
Remove version number from copyright headers
Matthew Wild <mwild1@gmail.com>
parents:
1495
diff
changeset
|
1 -- Prosody IM |
760
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
2 -- Copyright (C) 2008-2009 Matthew Wild |
90ce865eebd8
Update copyright notices for 2009
Matthew Wild <mwild1@gmail.com>
parents:
759
diff
changeset
|
3 -- Copyright (C) 2008-2009 Waqas Hussain |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
4 -- |
758 | 5 -- This project is MIT/X11 licensed. Please see the |
6 -- COPYING file in the source package for more information. | |
519
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
7 -- |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
8 |
cccd610a0ef9
Insert copyright/license headers
Matthew Wild <mwild1@gmail.com>
parents:
438
diff
changeset
|
9 |
1494
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
10 |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
11 local st = require "util.stanza" |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
12 |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
13 local jid_split = require "util.jid".split; |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
14 local t_concat = table.concat; |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
15 |
1495
6c745a108e68
mod_uptime: Use time of server start rather than module load
Matthew Wild <mwild1@gmail.com>
parents:
1494
diff
changeset
|
16 local start_time = prosody.start_time; |
1494
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
17 |
1524
a89fec6d76d2
mod_uptime: Fix bad uptime if module is loaded at startup
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
18 prosody.events.add_handler("server-started", function () start_time = prosody.start_time end); |
a89fec6d76d2
mod_uptime: Fix bad uptime if module is loaded at startup
Matthew Wild <mwild1@gmail.com>
parents:
1523
diff
changeset
|
19 |
1494
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
20 module:add_feature("jabber:iq:last"); |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
21 |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
22 module:add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
23 function (origin, stanza) |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
24 if stanza.tags[1].name == "query" then |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
25 if stanza.attr.type == "get" then |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
26 local node, host, resource = jid_split(stanza.attr.to); |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
27 if node or resource then |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
28 -- TODO |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
29 else |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
30 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))})); |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
31 return true; |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
32 end |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
33 end |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
34 end |
bdfa5274e111
mod_uptime: Convert to unix line endings
Matthew Wild <mwild1@gmail.com>
parents:
896
diff
changeset
|
35 end); |