Software /
code /
prosody
Comparison
util/caps.lua @ 6791:e813e8cf6046
Merge 0.10->trunk
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Thu, 20 Aug 2015 13:05:22 +0200 |
parent | 6777:5de6b93d0190 |
child | 8555:4f0f5b49bb03 |
comparison
equal
deleted
inserted
replaced
6776:4412a2307c89 | 6791:e813e8cf6046 |
---|---|
10 local sha1 = require "util.hashes".sha1; | 10 local sha1 = require "util.hashes".sha1; |
11 | 11 |
12 local t_insert, t_sort, t_concat = table.insert, table.sort, table.concat; | 12 local t_insert, t_sort, t_concat = table.insert, table.sort, table.concat; |
13 local ipairs = ipairs; | 13 local ipairs = ipairs; |
14 | 14 |
15 module "caps" | 15 local _ENV = nil; |
16 | 16 |
17 function calculate_hash(disco_info) | 17 local function calculate_hash(disco_info) |
18 local identities, features, extensions = {}, {}, {}; | 18 local identities, features, extensions = {}, {}, {}; |
19 for _, tag in ipairs(disco_info) do | 19 for _, tag in ipairs(disco_info) do |
20 if tag.name == "identity" then | 20 if tag.name == "identity" then |
21 t_insert(identities, (tag.attr.category or "").."\0"..(tag.attr.type or "").."\0"..(tag.attr["xml:lang"] or "").."\0"..(tag.attr.name or "")); | 21 t_insert(identities, (tag.attr.category or "").."\0"..(tag.attr.type or "").."\0"..(tag.attr["xml:lang"] or "").."\0"..(tag.attr.name or "")); |
22 elseif tag.name == "feature" then | 22 elseif tag.name == "feature" then |
56 local S = identities..features..extensions; | 56 local S = identities..features..extensions; |
57 local ver = base64(sha1(S)); | 57 local ver = base64(sha1(S)); |
58 return ver, S; | 58 return ver, S; |
59 end | 59 end |
60 | 60 |
61 return _M; | 61 return { |
62 calculate_hash = calculate_hash; | |
63 }; |