-
Notifications
You must be signed in to change notification settings - Fork 426
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
C2s/ejabberd #3805
Conversation
5865f40
to
38c2219
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportBase: 70.72% // Head: 71.95% // Increases project coverage by
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
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. |
3668310
to
af3a4cc
Compare
This comment was marked as outdated.
This comment was marked as outdated.
af3a4cc
to
c8155b6
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
86f7795
to
6102957
Compare
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
3f48827
to
ed9588b
Compare
small_tests_24 / small_tests / ed9588b small_tests_25 / small_tests / ed9588b ldap_mnesia_24 / ldap_mnesia / ed9588b ldap_mnesia_25 / ldap_mnesia / ed9588b dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / ed9588b internal_mnesia_25 / internal_mnesia / ed9588b pgsql_mnesia_24 / pgsql_mnesia / ed9588b elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / ed9588b dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / ed9588b dynamic_domains_mysql_redis_25 / mysql_redis / ed9588b riak_mnesia_24 / riak_mnesia / ed9588b pgsql_mnesia_25 / pgsql_mnesia / ed9588b mysql_redis_25 / mysql_redis / ed9588b mssql_mnesia_25 / odbc_mssql_mnesia / ed9588b 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}]}]}} 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}]}]}} 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}]}]}} 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}]}]}} dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / ed9588b mssql_mnesia_25 / odbc_mssql_mnesia / ed9588b |
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"}}}, |
There was a problem hiding this comment.
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.
There was a problem hiding this 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 |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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.
src/c2s/mongoose_c2s_ranch.erl
Outdated
-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 |
There was a problem hiding this comment.
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], |
There was a problem hiding this comment.
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.
hibernate_after => 0, | ||
c2s_state_timeout => 5000, | ||
backwards_compatible_session => true}, |
There was a problem hiding this comment.
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 🤷🏽
src/mod_websockets.erl
Outdated
hibernate_after => 0, | ||
c2s_state_timeout => 5000, | ||
backwards_compatible_session => true}, |
There was a problem hiding this comment.
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.
There was a problem hiding this 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
src/c2s/mongoose_c2s_socket.erl
Outdated
{ok, C2SSocket#c2s_socket{state = NewState}}; | ||
Error -> | ||
Error | ||
end. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indentation is off
src/c2s/mongoose_c2s_socket.erl
Outdated
-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 -> |
There was a problem hiding this comment.
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.
This comment was marked as outdated.
This comment was marked as outdated.
651690d
to
c767a27
Compare
small_tests_24 / small_tests / c767a27 small_tests_25 / small_tests / c767a27 ldap_mnesia_24 / ldap_mnesia / c767a27 ldap_mnesia_25 / ldap_mnesia / c767a27 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / c767a27 pgsql_mnesia_24 / pgsql_mnesia / c767a27 internal_mnesia_25 / internal_mnesia / c767a27 elasticsearch_and_cassandra_25 / elasticsearch_and_cassandra_mnesia / c767a27 dynamic_domains_pgsql_mnesia_25 / pgsql_mnesia / c767a27 dynamic_domains_mysql_redis_25 / mysql_redis / c767a27 riak_mnesia_24 / riak_mnesia / c767a27 mysql_redis_25 / mysql_redis / c767a27 pgsql_mnesia_25 / pgsql_mnesia / c767a27 mssql_mnesia_25 / odbc_mssql_mnesia / c767a27 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}]}]}} dynamic_domains_mssql_mnesia_25 / odbc_mssql_mnesia / c767a27 mssql_mnesia_25 / odbc_mssql_mnesia / c767a27 |
There was a problem hiding this 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! 🎉🎉🎉
Remove
ejabberd_c2s
module completely.