30 local supported = {}; -- by the server |
30 local supported = {}; -- by the server |
31 for mech in pairs(mechanisms) do |
31 for mech in pairs(mechanisms) do |
32 table.insert(supported, mech); |
32 table.insert(supported, mech); |
33 end |
33 end |
34 if not supported[1] then |
34 if not supported[1] then |
35 stream:event("authentication-failure", { condition = "no-supported-sasl-mechanisms" }); |
35 stream:event("authentication-failure", { condition = "no-supported-sasl-mechanisms", mechanisms = mechanisms }); |
36 stream:close(); |
36 stream:close(); |
37 return; |
37 return; |
38 end |
38 end |
39 table.sort(supported, function (a, b) return preference[a] > preference[b]; end); |
39 table.sort(supported, function (a, b) return preference[a] > preference[b]; end); |
40 local mechanism, initial_data = supported[1]; |
40 local mechanism, initial_data = supported[1]; |