Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C2s/ejabberd #3805

Merged
merged 4 commits into from
Oct 28, 2022
Merged

C2s/ejabberd #3805

merged 4 commits into from
Oct 28, 2022

Conversation

kamilwaz
Copy link

Remove ejabberd_c2s module completely.

@kamilwaz kamilwaz changed the base branch from master to feature/mongoose_c2s October 11, 2022 07:56
@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@codecov
Copy link

codecov bot commented Oct 11, 2022

Codecov Report

Base: 70.72% // Head: 71.95% // Increases project coverage by +1.23% 🎉

Coverage data is based on head (c767a27) compared to base (bbc6885).
Patch coverage: 73.83% of modified lines in pull request are covered.

Additional details and impacted files
@@                   Coverage Diff                    @@
##           feature/mongoose_c2s    #3805      +/-   ##
========================================================
+ Coverage                 70.72%   71.95%   +1.23%     
========================================================
  Files                       536      535       -1     
  Lines                     35209    33922    -1287     
========================================================
- Hits                      24900    24408     -492     
+ Misses                    10309     9514     -795     
Impacted Files Coverage Δ
src/ejabberd_router.erl 78.57% <ø> (ø)
src/ejabberd_socket.erl 31.16% <ø> (+1.90%) ⬆️
src/ejabberd_sup.erl 85.71% <ø> (ø)
src/ejabberd_zlib.erl 0.00% <ø> (ø)
src/jlib.erl 80.34% <ø> (-1.16%) ⬇️
src/mod_ping.erl 98.43% <ø> (ø)
...rc/mongoose_client_api/mongoose_client_api_sse.erl 58.97% <ø> (ø)
src/mongoose_hooks.erl 89.40% <0.00%> (+2.61%) ⬆️
src/mongoose_iq.erl 85.00% <ø> (ø)
src/mongoose_tls.erl 2.50% <ø> (ø)
... and 45 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im

This comment was marked as outdated.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Oct 26, 2022

small_tests_24 / small_tests / ed9588b
Reports root / small


small_tests_25 / small_tests / ed9588b
Reports root / small


ldap_mnesia_24 / ldap_mnesia / ed9588b
Reports root/ big
OK: 1545 / Failed: 0 / User-skipped: 686 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / ed9588b
Reports root/ big
OK: 1545 / Failed: 0 / User-skipped: 686 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / ed9588b
Reports root/ big
OK: 3544 / Failed: 0 / User-skipped: 78 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / ed9588b
Reports root/ big
OK: 1634 / Failed: 0 / User-skipped: 597 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / ed9588b
Reports root/ big
OK: 3720 / Failed: 0 / User-skipped: 89 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / ed9588b
Reports root/ big
OK: 1968 / Failed: 0 / User-skipped: 598 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / ed9588b
Reports root/ big
OK: 3544 / Failed: 0 / User-skipped: 78 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / ed9588b
Reports root/ big
OK: 3518 / Failed: 0 / User-skipped: 104 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / ed9588b
Reports root/ big
OK: 1808 / Failed: 0 / User-skipped: 590 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / ed9588b
Reports root/ big
OK: 3720 / Failed: 0 / User-skipped: 89 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / ed9588b
Reports root/ big
OK: 3706 / Failed: 0 / User-skipped: 103 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / ed9588b
Reports root/ big
OK: 3716 / Failed: 4 / User-skipped: 89 / Auto-skipped: 0

service_domain_db_SUITE:db:db_could_sync_between_nodes
{error,
  {{badrpc,{'EXIT',{timeout,{gen_server,call,[service_domain_db,ping]}}}},
   [{distributed_helper,rpc,
      [#{node => mongooseim@localhost},service_domain_db,sync_local,[]],
      [{file,
         "/home/circleci/project/big_tests/tests/distributed_helper.erl"},
       {line,117}]},
    {service_domain_db_SUITE,sync_local,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1175}]},
    {service_domain_db_SUITE,sync,0,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1154}]},
    {service_domain_db_SUITE,db_could_sync_between_nodes,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,556}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log

service_domain_db_SUITE:db:db_deleted_from_one_node_while_service_disabled_on_another
{error,
  {{badrpc,timeout},
   [{distributed_helper,rpc,
      [#{node => mongooseim@localhost},service_domain_db,sync_local,[]],
      [{file,
         "/home/circleci/project/big_tests/tests/distributed_helper.erl"},
       {line,117}]},
    {service_domain_db_SUITE,sync_local,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1175}]},
    {service_domain_db_SUITE,sync,0,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1154}]},
    {service_domain_db_SUITE,
      db_deleted_from_one_node_while_service_disabled_on_another,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,561}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log

service_domain_db_SUITE:db:db_inserted_from_one_node_while_service_disabled_on_another
{error,
  {{badrpc,timeout},
   [{distributed_helper,rpc,
      [#{node => mongooseim2@localhost},service_domain_db,sync_local,[]],
      [{file,
         "/home/circleci/project/big_tests/tests/distributed_helper.erl"},
       {line,117}]},
    {service_domain_db_SUITE,sync_local,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1175}]},
    {service_domain_db_SUITE,
      db_inserted_from_one_node_while_service_disabled_on_another,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,579}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log

service_domain_db_SUITE:db:db_reinserted_from_one_node_while_service_disabled_on_another
{error,
  {{badrpc,timeout},
   [{distributed_helper,rpc,
      [#{node => mongooseim@localhost},service_domain_db,sync_local,[]],
      [{file,
         "/home/circleci/project/big_tests/tests/distributed_helper.erl"},
       {line,117}]},
    {service_domain_db_SUITE,sync_local,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1175}]},
    {service_domain_db_SUITE,sync,0,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,1154}]},
    {service_domain_db_SUITE,
      db_reinserted_from_one_node_while_service_disabled_on_another,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,586}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / ed9588b
Reports root/ big
OK: 3544 / Failed: 0 / User-skipped: 78 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / ed9588b
Reports root/ big
OK: 3720 / Failed: 0 / User-skipped: 89 / Auto-skipped: 0

@kamilwaz kamilwaz marked this pull request as ready for review October 26, 2022 12:31
rebar.config Outdated
@@ -112,8 +112,7 @@

%%% Other
{pa, {git, "https://github.com/erszcz/pa.git", {branch, "master"}}},
%% MR of jwerl - https://gitlab.com/glejeune/jwerl/-/merge_requests/13
{jwerl, {git, "https://gitlab.com/vkatsuba/jwerl.git", {branch, "refactoring/otp-24"}}},
{jwerl, {git, "https://gitlab.com/glejeune/jwerl.git", {tag, "1.2.0"}}},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we could use the hex version already btw.

Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few comments made, otherwise what an outstanding work! 😃

src/mod_caps.erl Outdated
Rs = case ejabberd_c2s:get_aux_field(caps_resources,
C2SState)
of
Rs = case mongoose_c2s:get_mod_state(StateData, ?MODULE) of
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm sad dialyzer doesn't fail on this one. get_mod_state will return {error, not_found} | term(), so this pattern-matching will very likely fail. Please re-check that the state stored is what is expected here, the ok tuple also seems off from a distance 🤔

src/mod_caps.erl Outdated
c2s_broadcast_recipients/5]).

%% for test cases
-export([delete_caps/1, make_disco_hash/2]).

-ignore_xref([c2s_broadcast_recipients/5, c2s_filter_packet/5, c2s_presence_in/4,
-ignore_xref([c2s_broadcast_recipients/5, c2s_filter_packet/5, user_receive_presence/3,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new hooks don't need to be added to ignore_xref, as we refer to them by their function object (fun ?MODULE:Function/3), xref knows they're used.

Comment on lines 115 to 121
-spec has_peer_cert(mongoose_c2s_socket:state(), mongoose_listener:options()) -> boolean().
has_peer_cert(#state{transport = fast_tls, socket = Socket}, #{tls := TlsOpts}) ->
case {fast_tls:get_verify_result(Socket), fast_tls:get_peer_certificate(Socket), TlsOpts} of
{0, {ok, _}, _} -> true;
{18, {ok, _}, #{verify_mode := selfsigned_peer}} -> true;
{_, {ok, _}, _} -> false;
{_, error, _} -> false
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you could move the comment from mongoose_c2s_socket that says %% 18 is OpenSSL's and fast_tls's error code for self-signed certs, so that that 18 ain't so magic.

@@ -928,7 +907,7 @@ check_for_sessions_to_replace(HostType, JID) ->
%% replacement for max_sessions. We need to check this at some point.
ReplacedRedundantSessions = check_existing_resources(HostType, LUser, LServer, LResource),
AllReplacedSessionPids = check_max_sessions(HostType, LUser, LServer, ReplacedRedundantSessions),
[Pid ! replaced || Pid <- AllReplacedSessionPids],
[mongoose_c2s:exit(Pid, <<"Replaced by new connection">>) || Pid <- AllReplacedSessionPids],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After this, we could remove the handle_info clause in mongoose_c2s that was catching the replaced message.

Comment on lines +212 to +214
hibernate_after => 0,
c2s_state_timeout => 5000,
backwards_compatible_session => true},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Huh, we should have these from the config, but anyway, nobody uses bosh, nor they should anyway 🤷🏽

Comment on lines 243 to 245
hibernate_after => 0,
c2s_state_timeout => 5000,
backwards_compatible_session => true},
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's a bit more important to have the correct config, websockets are ubiquitous. You can check them on the listener, using some mongoose_config function to get the listener config and then extract them. Or maybe better, they should be kept in the websocket state, #ws_state{}, from there we can correctly configure this.

Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Couple more comments I just noticed

{ok, C2SSocket#c2s_socket{state = NewState}};
Error ->
Error
end.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indentation is off

-spec handle_data(socket(), {tcp | ssl, term(), iodata()}) ->
iodata() | {raw, [term()]} | {error, term()}.
handle_data(#c2s_socket{module = Module, state = State},
{Transport, _Socket, _Data} = Payload) when Transport == tcp; Transport == ssl ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is only called by mongoose_c2s after it has already verified that the Transport tag is one of tcp or ssl, so it is probably not necessary here and we can expect dialyzer to catch any other related issue.

@mongoose-im

This comment was marked as outdated.

@mongoose-im
Copy link
Collaborator

mongoose-im commented Oct 27, 2022

small_tests_24 / small_tests / c767a27
Reports root / small


small_tests_25 / small_tests / c767a27
Reports root / small


ldap_mnesia_24 / ldap_mnesia / c767a27
Reports root/ big
OK: 1545 / Failed: 0 / User-skipped: 686 / Auto-skipped: 0


ldap_mnesia_25 / ldap_mnesia / c767a27
Reports root/ big
OK: 1545 / Failed: 0 / User-skipped: 686 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / c767a27
Reports root/ big
OK: 3544 / Failed: 0 / User-skipped: 78 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / c767a27
Reports root/ big
OK: 3720 / Failed: 0 / User-skipped: 89 / Auto-skipped: 0


internal_mnesia_25 / internal_mnesia / c767a27
Reports root/ big
OK: 1634 / Failed: 0 / User-skipped: 597 / Auto-skipped: 0


elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / c767a27
Reports root/ big
OK: 1968 / Failed: 0 / User-skipped: 598 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / c767a27
Reports root/ big
OK: 3544 / Failed: 0 / User-skipped: 78 / Auto-skipped: 0


dynamic_domains_mysql_redis_25 / mysql_redis / c767a27
Reports root/ big
OK: 3518 / Failed: 0 / User-skipped: 104 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / c767a27
Reports root/ big
OK: 1808 / Failed: 0 / User-skipped: 590 / Auto-skipped: 0


mysql_redis_25 / mysql_redis / c767a27
Reports root/ big
OK: 3706 / Failed: 0 / User-skipped: 103 / Auto-skipped: 0


pgsql_mnesia_25 / pgsql_mnesia / c767a27
Reports root/ big
OK: 3720 / Failed: 0 / User-skipped: 89 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / c767a27
Reports root/ big
OK: 3719 / Failed: 1 / User-skipped: 89 / Auto-skipped: 0

service_domain_db_SUITE:db:db_event_could_appear_with_lower_id
{error,
  {{badmatch,467},
   [{service_domain_db_SUITE,db_event_could_appear_with_lower_id,1,
      [{file,
         "/home/circleci/project/big_tests/tests/service_domain_db_SUITE.erl"},
       {line,686}]},
    {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1782}]},
    {test_server,run_test_case_eval1,6,
      [{file,"test_server.erl"},{line,1291}]},
    {test_server,run_test_case_eval,9,
      [{file,"test_server.erl"},{line,1223}]}]}}

Report log


dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / c767a27
Reports root/ big
OK: 3544 / Failed: 0 / User-skipped: 78 / Auto-skipped: 0


mssql_mnesia_25 / odbc_mssql_mnesia / c767a27
Reports root/ big
OK: 3720 / Failed: 0 / User-skipped: 89 / Auto-skipped: 0

Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no further comments, all left has been well captured in the backlog. Thanks so much for this big piece of work! 🎉🎉🎉

@NelsonVides NelsonVides merged commit 49eb66c into feature/mongoose_c2s Oct 28, 2022
@NelsonVides NelsonVides deleted the c2s/ejabberd branch October 28, 2022 02:48
@jacekwegr jacekwegr added this to the 6.1.0 milestone Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants