Software /
code /
prosody
Annotate
plugins/mod_uptime.lua @ 319:4a8a949c3870
Fix for putting TLS in stream:features for connections already using TLS. Thanks to albert for spotting.
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Sun, 16 Nov 2008 00:29:15 +0000 |
parent | 314:851f271d25b0 |
child | 421:63be85693710 |
rev | line source |
---|---|
235
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
1 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
2 local st = require "util.stanza" |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
3 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
4 local jid_split = require "util.jid".split; |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
5 local t_concat = table.concat; |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
6 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
7 local start_time = os.time(); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
8 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
9 add_iq_handler({"c2s", "s2sin"}, "jabber:iq:last", |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
10 function (origin, stanza) |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
11 if stanza.tags[1].name == "query" then |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
12 if stanza.attr.type == "get" then |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
13 local node, host, resource = jid_split(stanza.attr.to); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
14 if node or resource then |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
15 -- TODO |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
16 else |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
17 origin.send(st.reply(stanza):tag("query", {xmlns = "jabber:iq:last", seconds = tostring(os.difftime(os.time(), start_time))})); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
18 return true; |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
19 end |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
20 end |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
21 end |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
22 end); |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
23 |
6526df1a7277
Added mod_uptime: [XEP-0012: Last Activity] queries now work when directed at the server.
Waqas Hussain <waqas20@gmail.com>
parents:
diff
changeset
|
24 |