Software /
code /
prosody-modules
Annotate
mod_stanza_counter/mod_stanza_counter.lua @ 433:967757965dbd
mod_stanza_counter: tidbits, line break escapes.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Tue, 20 Sep 2011 21:21:06 +0000 |
parent | 432:23a6289a00bd |
child | 434:ac4a6cc5776c |
rev | line source |
---|---|
432
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
1 -- (C) 2011, Marco Cirillo (LW.Org) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
2 -- General Stanzas' Counter with web output. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
3 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
4 local jid_bare = require "util.jid".bare |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
5 local httpserver = require "net.httpserver" |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
6 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
7 module.host = "*" -- Needs to be global for stats web wise. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
8 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
9 local ports = module:get_option_array("stanza_counter_ports" or {{ port = 5280; base = "stanza-counter" }}) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
10 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
11 -- http handlers |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
12 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
13 local r_200 = "\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
14 <html>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
15 <head>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
16 <title>Prosody's Stanza Counter</title>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
17 <meta name=\"robots\" content=\"noindex, nofollow\" />\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
18 </head>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
19 \n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
20 <body>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
21 <h3>Incoming and Outgoing stanzas divided per type</h3>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
22 <p><strong>Incoming IQs</strong>: %d<br/>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
23 <strong>Outgoing IQs</strong>: %d<br/>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
24 <strong>Incoming Messages</strong>: %d<br/>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
25 <strong>Outgoing Messages</strong>: %d<br/>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
26 <strong>Incoming Presences</strong>: %d<br/>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
27 <strong>Outgoing Presences</strong>: %d<p>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
28 </body>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
29 \n |
433
967757965dbd
mod_stanza_counter: tidbits, line break escapes.
Marco Cirillo <maranda@lightwitch.org>
parents:
432
diff
changeset
|
30 </html>\n" |
432
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
31 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
32 local r_405 = "\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
33 <html>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
34 <head>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
35 <title>Prosody's Stanza Counter - Error</title>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
36 <meta name=\"robots\" content=\"noindex, nofollow\" />\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
37 </head>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
38 \n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
39 <body>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
40 <h3>Bad Method ... I only support GET.</h3>\n |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
41 </body>\n |
433
967757965dbd
mod_stanza_counter: tidbits, line break escapes.
Marco Cirillo <maranda@lightwitch.org>
parents:
432
diff
changeset
|
42 \n |
967757965dbd
mod_stanza_counter: tidbits, line break escapes.
Marco Cirillo <maranda@lightwitch.org>
parents:
432
diff
changeset
|
43 </html>\n" |
432
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
44 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
45 local function res(code, r, h) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
46 local response = { |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
47 status = code; |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
48 body = r; |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
49 } |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
50 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
51 if h then response.headers = h; end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
52 return response |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
53 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
54 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
55 local function req(method, body, request) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
56 if method = "GET" then |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
57 local forge_res = r_200:format(prosody.stanza_counter.iq["incoming"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
58 prosody.stanza_counter.iq["outgoing"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
59 prosody.stanza_counter.message["incoming"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
60 prosody.stanza_counter.message["outgoing"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
61 prosody.stanza_counter.presence["incoming"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
62 prosody.stanza_counter.presence["outgoing"]); |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
63 return res(200, forge_res) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
64 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
65 return res(405, r_405, {["Allow"] = "GET"}) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
66 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
67 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
68 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
69 -- Setup, Init functions. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
70 -- initialize function counter table on the global object on start |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
71 local function init_counter() |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
72 prosody.stanza_counter = { |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
73 iq = { incoming=0, outgoing=0 }, |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
74 message = { incoming=0, outgoing=0 }, |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
75 presence = { incoming=0, outgoing=0 } |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
76 } |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
77 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
78 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
79 -- init http interface |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
80 local function init_web() |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
81 httpserver.new_from_config(ports, req) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
82 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
83 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
84 -- Setup on server start |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
85 local function setup() |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
86 init_counter(); init_web(); |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
87 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
88 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
89 -- Basic Stanzas' Counters |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
90 local function iq_callback(check) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
91 return function(self) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
92 local origin, stanza = self.origin, self.stanza |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
93 if not prosody.stanza_counter then init_counter() end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
94 if check |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
95 if not stanza.attr.to or hosts[jid_bare(stanza.attr.to)] then return nil; |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
96 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
97 prosody.stanza_counter.iq["outgoing"] = prosody.stanza_counter.iq["outgoing"] + 1 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
98 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
99 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
100 prosody.stanza_counter.iq["incoming"] = prosody.stanza_counter.iq["incoming"] + 1 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
101 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
102 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
103 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
104 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
105 local function message_callback(check) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
106 return function(self) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
107 local origin, stanza = self.origin, self.stanza |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
108 if not prosody.stanza_counter then init_counter() end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
109 if check |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
110 if not stanza.attr.to or hosts[jid_bare(stanza.attr.to)] then return nil; |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
111 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
112 prosody.stanza_counter.message["outgoing"] = prosody.stanza_counter.message["outgoing"] + 1 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
113 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
114 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
115 prosody.stanza_counter.message["incoming"] = prosody.stanza_counter.message["incoming"] + 1 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
116 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
117 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
118 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
119 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
120 local function presence_callback(check) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
121 return function(self) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
122 local origin, stanza = self.origin, self.stanza |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
123 if not prosody.stanza_counter then init_counter() end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
124 if check |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
125 if not stanza.attr.to or hosts[jid_bare(stanza.attr.to)] then return nil; |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
126 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
127 prosody.stanza_counter.presence["outgoing"] = prosody.stanza_counter.presence["outgoing"] + 1 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
128 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
129 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
130 prosody.stanza_counter.presence["incoming"] = prosody.stanza_counter.presence["incoming"] + 1 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
131 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
132 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
133 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
134 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
135 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
136 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
137 -- Hook all pre-stanza events. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
138 module:hook("pre-iq/bare", iq_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
139 module:hook("pre-iq/full", iq_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
140 module:hook("pre-iq/host", iq_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
141 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
142 module:hook("pre-message/bare", mes_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
143 module:hook("pre-message/full", mes_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
144 module:hook("pre-message/host", mes_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
145 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
146 module:hook("pre-presence/bare", pre_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
147 module:hook("pre-presence/full", pre_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
148 module:hook("pre-presence/host", pre_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
149 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
150 -- Hook all stanza events. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
151 module:hook("iq/bare", iq_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
152 module:hook("iq/full", iq_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
153 module:hook("iq/host", iq_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
154 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
155 module:hook("message/bare", mes_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
156 module:hook("message/full", mes_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
157 module:hook("message/host", mes_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
158 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
159 module:hook("presence/bare", pre_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
160 module:hook("presence/full", pre_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
161 module:hook("presence/host", pre_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
162 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
163 -- Hook server start to initialize the counter. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
164 module:hook("server-started", setup) |