core/servermanager.lua
author Matthew Wild <mwild1@gmail.com>
Wed, 01 May 2013 13:54:44 +0100
branchtls
changeset 5556 7407b1160b46
parent 43 03dc9df59368
child 111 0abe771b43c6
permissions -rw-r--r--
Close 'tls' branch
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
43
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
     1
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
     2
local st = require "util.stanza";
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
     3
local send = require "core.sessionmanager".send_to_session;
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
     4
local xmlns_stanzas ='urn:ietf:params:xml:ns:xmpp-stanzas';
30
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     5
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     6
require "modulemanager"
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     7
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     8
-- Handle stanzas that were addressed to the server (whether they came from c2s, s2s, etc.)
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
     9
function handle_stanza(origin, stanza)
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    10
	-- Use plugins
43
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    11
	if not modulemanager.handle_stanza(origin, stanza) then
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    12
		if stanza.name == "iq" then
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    13
			local reply = st.reply(stanza);
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    14
			reply.attr.type = "error";
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    15
			reply:tag("error", { type = "cancel" })
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    16
				:tag("service-unavailable", { xmlns = xmlns_stanzas });
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    17
			send(origin, reply);
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    18
		end
03dc9df59368 Reply to unhandled iq's with service-unavailable
Matthew Wild <mwild1@gmail.com>
parents: 30
diff changeset
    19
	end
30
bcf539295f2d Huge commit to:
Matthew Wild <mwild1@gmail.com>
parents:
diff changeset
    20
end