mod_sasl2_bind2/mod_sasl2_bind2.lua
changeset 5047 17b87fffdb91
parent 5043 c0d243b27e64
child 5048 f64d834ba744
equal deleted inserted replaced
5046:166fd192f39c 5047:17b87fffdb91
     7 local xmlns_bind2 = "urn:xmpp:bind2:1";
     7 local xmlns_bind2 = "urn:xmpp:bind2:1";
     8 local xmlns_sasl2 = "urn:xmpp:sasl:2";
     8 local xmlns_sasl2 = "urn:xmpp:sasl:2";
     9 
     9 
    10 -- Advertise what we can do
    10 -- Advertise what we can do
    11 
    11 
    12 module:hook("stream-features", function(event)
    12 module:hook("advertise-sasl-features", function(event)
    13 	local origin, features = event.origin, event.features;
    13 	local bind = st.stanza("bind", { xmlns = xmlns_bind2 });
       
    14 	local inline = st.stanza("inline");
       
    15 	module:fire_event("advertise-bind-features", { origin = event.session, features = inline });
       
    16 	bind:add_direct_child(inline);
    14 
    17 
    15 	if origin.type ~= "c2s_unauthed" then
    18 	event.features:add_direct_child(bind);
    16 		return;
       
    17 	end
       
    18 
       
    19 	local inline = st.stanza("inline", { xmlns = xmlns_bind2 });
       
    20 	module:fire_event("advertise-bind-features", { origin = origin, features = inline });
       
    21 	features:add_direct_child(inline);
       
    22 end, 1);
       
    23 
       
    24 module:hook("advertise-sasl-features", function(event)
       
    25 	event.features:tag("bind", { xmlns = xmlns_bind2 }):up();
       
    26 end, 1);
    19 end, 1);
    27 
    20 
    28 -- Helper to actually bind a resource to a session
    21 -- Helper to actually bind a resource to a session
    29 
    22 
    30 local function do_bind(session, bind_request)
    23 local function do_bind(session, bind_request)