aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMatthew Wild <mwild1@gmail.com>2010-06-02 17:51:39 +0100
committerMatthew Wild <mwild1@gmail.com>2010-06-02 17:51:39 +0100
commite9448c71ce7e23b56ff9d24385e4fec18f5144a2 (patch)
tree2c3d40c60df3dfed3e15717b6c7b076a129cb4aa /net
parent828f40f911a2f14ed4a83ce8c70e203887af3361 (diff)
downloadprosody-e9448c71ce7e23b56ff9d24385e4fec18f5144a2.tar.gz
prosody-e9448c71ce7e23b56ff9d24385e4fec18f5144a2.zip
xmppclient_listener: Add filters for incoming bytes and stanzas
Diffstat (limited to 'net')
-rw-r--r--net/xmppclient_listener.lua20
1 files changed, 15 insertions, 5 deletions
diff --git a/net/xmppclient_listener.lua b/net/xmppclient_listener.lua
index 49b0e7f9..623a98c8 100644
--- a/net/xmppclient_listener.lua
+++ b/net/xmppclient_listener.lua
@@ -138,14 +138,24 @@ function xmppclient.onconnect(conn)
session.stream:reset();
end
+ local filter = session.filter;
function session.data(data)
- local ok, err = stream:feed(data);
- if ok then return; end
- log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
- session:close("xml-not-well-formed");
+ data = filter("bytes/in", data);
+ if data then
+ local ok, err = stream:feed(data);
+ if ok then return; end
+ log("debug", "Received invalid XML (%s) %d bytes: %s", tostring(err), #data, data:sub(1, 300):gsub("[\r\n]+", " "):gsub("[%z\1-\31]", "_"));
+ session:close("xml-not-well-formed");
+ end
end
- session.dispatch_stanza = stream_callbacks.handlestanza;
+ local handlestanza = stream_callbacks.handlestanza;
+ function session.dispatch_stanza(session, stanza)
+ stanza = filter("stanzas/in", stanza);
+ if stanza then
+ return handlestanza(session, stanza);
+ end
+ end
end
function xmppclient.onincoming(conn, data)