Comparison

mod_auth_external/mod_auth_external.lua @ 1343:7dbde05b48a9

all the things: Remove trailing whitespace
author Florian Zeitz <florob@babelmonkeys.de>
date Tue, 11 Mar 2014 18:44:01 +0100
parent 1195:f502cbffbdd4
child 1997:199fb0a82c0a
comparison
equal deleted inserted replaced
1342:0ae065453dc9 1343:7dbde05b48a9
83 end 83 end
84 end 84 end
85 85
86 function do_query(kind, username, password) 86 function do_query(kind, username, password)
87 if not username then return nil, "not-acceptable"; end 87 if not username then return nil, "not-acceptable"; end
88 88
89 local query = (password and "%s:%s:%s:%s" or "%s:%s:%s"):format(kind, username, host, password); 89 local query = (password and "%s:%s:%s:%s" or "%s:%s:%s"):format(kind, username, host, password);
90 local len = #query 90 local len = #query
91 if len > 1000 then return nil, "policy-violation"; end 91 if len > 1000 then return nil, "policy-violation"; end
92 92
93 if script_type == "ejabberd" then 93 if script_type == "ejabberd" then
94 local lo = len % 256; 94 local lo = len % 256;
95 local hi = (len - lo) / 256; 95 local hi = (len - lo) / 256;
96 query = string.char(hi, lo)..query; 96 query = string.char(hi, lo)..query;
97 elseif script_type == "generic" then 97 elseif script_type == "generic" then
98 query = query..'\n'; 98 query = query..'\n';
99 end 99 end
100 100
101 local response, err = send_query(query); 101 local response, err = send_query(query);
102 if not response then 102 if not response then
103 log("warn", "Error while waiting for result from auth process: %s", err or "unknown error"); 103 log("warn", "Error while waiting for result from auth process: %s", err or "unknown error");
104 elseif (script_type == "ejabberd" and response == "\0\2\0\0") or 104 elseif (script_type == "ejabberd" and response == "\0\2\0\0") or
105 (script_type == "generic" and response:gsub("\r?\n$", "") == "0") then 105 (script_type == "generic" and response:gsub("\r?\n$", "") == "0") then