Conversation
Key assumptions:
- Capabilities are stored once for each entity.
- There are two mappings stored in CETS:
1. hash -> features
It is stored until the next downtime.
2. jid -> features
It is stored until the client disconnects, sends different caps
or a presence without caps. Directed presence is always ignored.
- Capabilities are stored only for local users.
This simplifies the implementation. PubSub supports only local users
anyway. Previously, caps were stored for remote users, but the actual
features were the ones of presence recipients instead of senders,
so it was completely broken.
- When a hash of client's caps is not known, the server sends a disco request.
For that client, caps will stay unknown until the response is received.
This may cause a few requests to be sent after a cold start, but the caps
will become known quickly, i.e. after the first response is
received.
- The hash of the server disco info is stored only once per host type
in order to avoid recomputation for each session. This is calculated
lazily to avoid the case when some modules are not started yet,
and features are incomplete. Additionally, the server now checks
if the client asks for the correct hash when querying server caps.
- Include c2s data in caps_recognised - Remove the obsolete get_pep_recipient and filter_pep_recipient
The approach was to minimise changes because of the upcoming full rework of PubSub. Main changes: - Improve handling of module deps - Store presence subscribers in Acc on user_send_iq. This Acc will be then used when the notifications are broadcasted. - Read the caps of recipients using the new mod_caps API instead of using the obsolete foreign events.
- Test hash generation with the examples from XEP-0115. - Test API and the backend module. - Update config tests.
- Capture various caps use cases in disco_and_caps_SUITE. Some of them were untested and/or incorrectly handled before. Remove pep_caps_test from pep_SUITE because of duplication. - Update native_bookmarks_test in pep_SUITE, because it had race conditions. New mod_caps is faster, triggering them way more often. - Update tests in pep_SUITE after fixing the handling of unidirectional presence subscriptions. - Update send_caps_after login_test. There is on race condition anymore, and this now also checks the unchanged caps. - Export common caps helpers to caps_helper.
- It only supports CETS. - It has different options now.
This is the first module not working with the mnesia internal database, so test helpers needed extending to support providing global options while testing host config.
- Introduce a new 'versions' option with a list of supported versions. XEP-0115 becomes v1, and XEP-0390 becomes v2. - Add the corresponding caps features to disco responses. - Fix the issue, where a query to an invalid node would still return the caps namespace. - Advertise the corresponding server capabilities in stream features. - Consume and verify the corresponding client capabilities. - Attempt to request caps from the client in the order of configured versions. - Pass the version to the hash generating API.
- Rework encoding to implement the common part only once.
- Add detailed description and comments on all protocol details.
- Try to support both XEPs whenever possible:
v1: becomes more strict than before, but all within XEP-0115.
v2: in line with XEP-0390 except some cases listed in 'moduledoc'.
- Support more hashing functions. Skip ones not supported in Erlang.
- Make the check for supported algorithms more robust,
because some hashing algorithms are not supported e.g. in older
LibreSSL versions.
- Add examples from XEP-0390; adjust the XEP-0115 ones for consistency - Shuffle the complex responses more thoroughly to check sorting - Perform hashing tests for both v1 and v2 - Test all supported hashing algorithms. - Check the corner cases for v1 and v2, and document the tested behaviour with sources.
- Extract reusable helpers to escalus. - Run caps tests in disco_and_caps_SUITE for v1 and v2. Both versions are enabled on the server (as by default), and the client decides which one to use. - Check some previously missed corner cases: 1) Ask for the server capabilities with a malformed/incorrect node 2) Respond to the disco#info request with invalid elements
MIM-2647 Entity Capabilities 2.0 (XEP-0390)
MIM-2652 Document the migration for mod_caps
- Fix the hash namespace, and update its name to make it more obvious it is version 2 - Drop support for shake* algorithms not mentioned in XEP-0414 - Drop support for MD5 algorithm, which is a 'MUST NOT' in XEP-0414 - Advertise hash features as required by XEP-0300 section 5 Ex. 2
Align mod_caps hashing with XEP-0300 and XEP-0414
|
CircleCI results for 70ae6f9 elasticsearch_and_cassandra_latest / elasticsearch_and_cassandra_mnesia / 70ae6f9 small_tests_legacy / small_tests / 70ae6f9 small_tests_latest / small_tests / 70ae6f9 small_tests_latest_arm64 / small_tests / 70ae6f9 ldap_mnesia_legacy / ldap_mnesia / 70ae6f9 ldap_mnesia_latest / ldap_mnesia / 70ae6f9 internal_mnesia_latest / internal_mnesia / 70ae6f9 dynamic_domains_mysql_redis_latest / mysql_redis / 70ae6f9 dynamic_domains_pgsql_mnesia_legacy / pgsql_mnesia / 70ae6f9 dynamic_domains_pgsql_mnesia_latest / pgsql_mnesia / 70ae6f9 pgsql_cets_latest / pgsql_cets / 70ae6f9 pgsql_mnesia_legacy / pgsql_mnesia / 70ae6f9 pgsql_mnesia_latest / pgsql_mnesia / 70ae6f9 cockroachdb_cets_latest / cockroachdb_cets / 70ae6f9 mysql_redis_latest / mysql_redis / 70ae6f9 |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #4681 +/- ##
==========================================
+ Coverage 85.70% 85.76% +0.06%
==========================================
Files 551 551
Lines 33195 33166 -29
==========================================
- Hits 28449 28445 -4
+ Misses 4746 4721 -25 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Merge the feature branch with new
mod_capsimplementation.Changes (all previously reviewed):