Comparison

mod_firewall/README.markdown @ 4235:45606c9f529a

mod_firewall: Improve 'INSPECT' comparison operator documentation
author Matthew Wild <mwild1@gmail.com>
date Fri, 06 Nov 2020 11:16:48 +0000
parent 4169:ae738969f38a
child 4236:c316ad1087d4
comparison
equal deleted inserted replaced
4234:f31eac6b2e9c 4235:45606c9f529a
327 path ends with a '\#' then the text content of the last element will be 327 path ends with a '\#' then the text content of the last element will be
328 returned. If the path ends with '@name' then the value of the attribute 328 returned. If the path ends with '@name' then the value of the attribute
329 'name' will be returned. 329 'name' will be returned.
330 330
331 You can use INSPECT to test for the existence of an element or attribute, 331 You can use INSPECT to test for the existence of an element or attribute,
332 or you can see if it is equal to a string by appending `=STRING` (as in the 332 or you can check if it matches a specific value, e.g. by appending `=VALUE`
333 example above). Finally, you can also test whether it matches a given Lua 333 (like in the example above, that checks if the content of username is 'admin').
334 pattern by using `~=PATTERN`. 334
335 335 #### INSPECT comparison operators
336 INSPECT is somewhat slower than the other stanza matching conditions. To 336
337 As well as checking for an exact string match, there are some other modifiers
338 you can apply to the comparison:
339
340 Comparison Matches when
341 ------------- -------------------------------------------------------
342 `=` The value is exactly the given string.
343 `/=` The value is or *contains* the given string (e.g. `/=admin` would match `administrator` or `myadmin`).
344 `~=` The value matches the given [Lua pattern](https://www.lua.org/manual/5.2/manual.html#6.4.1).
345
346 Finally, if the comparison operator is preceded by a `$` character, [expressions](#expressions)
347 will be interpreted in the string following the comparison operator.
348
349 e.g. `INSPECT: {jabber:iq:register}query/username}$/=$(session.host)` would match
350 if the username of an account registration contained the session's current hostname
351 somewhere in it.
352
353 #### INSPECT performance
354
355 INSPECT can be somewhat slower than the other stanza matching conditions. To
337 minimise performance impact, always place it below other faster 356 minimise performance impact, always place it below other faster
338 condition checks where possible (e.g. above we first checked KIND, TYPE 357 condition checks where possible (e.g. in the example above we first checked KIND,
339 and PAYLOAD matched before INSPECT). 358 TYPE and PAYLOAD matched what we wanted before reaching the INSPECT rule).
340 359
341 ### Roster 360 ### Roster
342 361
343 These functions access the roster of the recipient (only). Therefore they cannot (currently) 362 These functions access the roster of the recipient (only). Therefore they cannot (currently)
344 be used in some chains, such as for outgoing messages (the recipient may be on another server). 363 be used in some chains, such as for outgoing messages (the recipient may be on another server).