Mercurial > prosody-modules
annotate mod_stanza_counter/mod_stanza_counter.lua @ 432:23a6289a00bd
mod_stanza_counter: initial draft.
author | Marco Cirillo <maranda@lightwitch.org> |
---|---|
date | Tue, 20 Sep 2011 21:15:29 +0000 |
parents | |
children | 967757965dbd |
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 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
30 </html>" |
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 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
42 \n" |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
43 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
44 local function res(code, r, h) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
45 local response = { |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
46 status = code; |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
47 body = r; |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
48 } |
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 if h then response.headers = h; end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
51 return response |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
52 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
53 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
54 local function req(method, body, request) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
55 if method = "GET" then |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
56 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
|
57 prosody.stanza_counter.iq["outgoing"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
58 prosody.stanza_counter.message["incoming"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
59 prosody.stanza_counter.message["outgoing"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
60 prosody.stanza_counter.presence["incoming"], |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
61 prosody.stanza_counter.presence["outgoing"]); |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
62 return res(200, forge_res) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
63 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
64 return res(405, r_405, {["Allow"] = "GET"}) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
65 end |
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 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
68 -- Setup, Init functions. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
69 -- initialize function counter table on the global object on start |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
70 local function init_counter() |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
71 prosody.stanza_counter = { |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
72 iq = { incoming=0, outgoing=0 }, |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
73 message = { incoming=0, outgoing=0 }, |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
74 presence = { incoming=0, outgoing=0 } |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
75 } |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
76 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
77 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
78 -- init http interface |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
79 local function init_web() |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
80 httpserver.new_from_config(ports, req) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
81 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
82 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
83 -- Setup on server start |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
84 local function setup() |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
85 init_counter(); init_web(); |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
86 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
87 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
88 -- Basic Stanzas' Counters |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
89 local function iq_callback(check) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
90 return function(self) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
91 local origin, stanza = self.origin, self.stanza |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
92 if not prosody.stanza_counter then init_counter() end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
93 if check |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
94 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
|
95 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
96 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
|
97 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
98 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
99 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
|
100 end |
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 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
104 local function message_callback(check) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
105 return function(self) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
106 local origin, stanza = self.origin, self.stanza |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
107 if not prosody.stanza_counter then init_counter() end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
108 if check |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
109 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
|
110 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
111 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
|
112 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
113 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
114 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
|
115 end |
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 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
119 local function presence_callback(check) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
120 return function(self) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
121 local origin, stanza = self.origin, self.stanza |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
122 if not prosody.stanza_counter then init_counter() end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
123 if check |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
124 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
|
125 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
126 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
|
127 end |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
128 else |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
129 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
|
130 end |
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 |
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 -- Hook all pre-stanza events. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
137 module:hook("pre-iq/bare", iq_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
138 module:hook("pre-iq/full", iq_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
139 module:hook("pre-iq/host", iq_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
140 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
141 module:hook("pre-message/bare", mes_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
142 module:hook("pre-message/full", mes_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
143 module:hook("pre-message/host", mes_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
144 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
145 module:hook("pre-presence/bare", pre_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
146 module:hook("pre-presence/full", pre_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
147 module:hook("pre-presence/host", pre_callback(true), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
148 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
149 -- Hook all stanza events. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
150 module:hook("iq/bare", iq_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
151 module:hook("iq/full", iq_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
152 module:hook("iq/host", iq_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
153 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
154 module:hook("message/bare", mes_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
155 module:hook("message/full", mes_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
156 module:hook("message/host", mes_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
157 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
158 module:hook("presence/bare", pre_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
159 module:hook("presence/full", pre_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
160 module:hook("presence/host", pre_callback(false), 140) |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
161 |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
162 -- Hook server start to initialize the counter. |
23a6289a00bd
mod_stanza_counter: initial draft.
Marco Cirillo <maranda@lightwitch.org>
parents:
diff
changeset
|
163 module:hook("server-started", setup) |