Software /
code /
prosody
Comparison
util/jid.lua @ 3375:29e51e1c7c3d
util.jid: compare() added, with some tests.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 16 Jul 2010 00:36:02 +0200 |
parent | 2923:b7049746bd29 |
child | 3480:97831dfe7f72 |
comparison
equal
deleted
inserted
replaced
3373:cd6836586a6a | 3375:29e51e1c7c3d |
---|---|
76 return host; | 76 return host; |
77 end | 77 end |
78 return nil; -- Invalid JID | 78 return nil; -- Invalid JID |
79 end | 79 end |
80 | 80 |
81 function compare(jid, acl) | |
82 -- compare jid to single acl rule | |
83 -- TODO compare to table of rules? | |
84 local jid_node, jid_host, jid_resource = _split(jid); | |
85 local acl_node, acl_host, acl_resource = _split(acl); | |
86 if ((acl_node ~= nil and acl_node == jid_node) or acl_node == nil) and | |
87 ((acl_host ~= nil and acl_host == jid_host) or acl_host == nil) and | |
88 ((acl_resource ~= nil and acl_resource == jid_resource) or acl_resource == nil) then | |
89 return true | |
90 end | |
91 return false | |
92 end | |
93 | |
81 return _M; | 94 return _M; |