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

Store listener config in a map #3495

Merged
merged 11 commits into from
Jan 12, 2022
Merged

Store listener config in a map #3495

merged 11 commits into from
Jan 12, 2022

Conversation

chrzaszcz
Copy link
Member

@chrzaszcz chrzaszcz commented Jan 10, 2022

Store configured listeners in mongoose_config maps instead of tuples with nested structures inside.

Example - before:

{{5222, {0, 0, 0, 0}, tcp},
        ejabberd_c2s,
        [{access, c2s},
         {max_stanza_size, 65536},
         {shaper, c2s_shaper},
         {certfile, "tools/ssl/mongooseim/server.pem"},
         {dhfile, "tools/ssl/mongooseim/dh_server.pem"},
         starttls,
         {zlib, 10000}]}

After:

#{access => c2s,
  ip_address => "0",
  ip_tuple => {0, 0, 0, 0},
  ip_version => 4,
  max_stanza_size => 65536,
  module => ejabberd_c2s,
  port => 5222,
  proto => tcp,
  shaper => c2s_shaper,
  tls => [{certfile, "priv/dc1.pem"}, {dhfile, "priv/dh.pem"}, starttls],
  zlib => 10000}

Other changes:

  • All validation is now specified in the config spec. This required updating certificate paths in test files to existing ones.
  • Listener config handling is extracted to a separate module.
  • TLS options left in the tls option.

Note: Nested options, e.g. TLS are left unchanged for now. The modules option for HTTP handlers modules might need renaming to avoid confusion with module. File presence checks need to be added for some nested options as well.

@codecov
Copy link

codecov bot commented Jan 10, 2022

Codecov Report

Merging #3495 (80c2195) into master (a673d03) will increase coverage by 0.01%.
The diff coverage is 92.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3495      +/-   ##
==========================================
+ Coverage   80.96%   80.97%   +0.01%     
==========================================
  Files         416      417       +1     
  Lines       32348    32276      -72     
==========================================
- Hits        26189    26134      -55     
+ Misses       6159     6142      -17     
Impacted Files Coverage Δ
src/config/mongoose_config_utils.erl 0.00% <ø> (-30.00%) ⬇️
src/mongoose_udp_listener.erl 38.46% <50.00%> (ø)
src/mongoose_tcp_listener.erl 76.59% <75.00%> (ø)
src/ejabberd_listener.erl 61.70% <89.47%> (-8.30%) ⬇️
src/mongoose_listener_config.erl 92.85% <92.85%> (ø)
src/config/mongoose_config_parser_toml.erl 97.81% <100.00%> (ø)
src/config/mongoose_config_spec.erl 99.22% <100.00%> (-0.02%) ⬇️
...stem_metrics/mongoose_system_metrics_collector.erl 93.81% <100.00%> (+2.74%) ⬆️
src/ejabberd_zlib.erl 56.75% <0.00%> (-10.82%) ⬇️
src/http_upload/mod_http_upload.erl 94.62% <0.00%> (-2.16%) ⬇️
... and 8 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a673d03...80c2195. Read the comment docs.

@mongoose-im

This comment has been minimized.

@mongoose-im

This comment has been minimized.

@mongoose-im

This comment has been minimized.

@mongoose-im

This comment has been minimized.

@mongoose-im

This comment has been minimized.

Previously the processing continued.
Now it is stopped and the errors are returned, as expected.
@mongoose-im

This comment has been minimized.

@mongoose-im

This comment has been minimized.

Replace the nested tuples with maps that are easier to work with.

- Put config processing in a new module.
- Keep the opts passed to listeners unchanged for now.
- Place TLS options under the 'tls' key for now.
- Validate the presence of certificate files in the config.

Further improvements of particular listeners will be done in new PR's.
Also: change cert paths to existing ones
Also: start listeners with supervisors.
@mongoose-im
Copy link
Collaborator

mongoose-im commented Jan 12, 2022

small_tests_24 / small_tests / 2e93602
Reports root / small


small_tests_23 / small_tests / 2e93602
Reports root / small


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 2e93602
Reports root/ big
OK: 2690 / Failed: 0 / User-skipped: 231 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 2e93602
Reports root/ big
OK: 2690 / Failed: 0 / User-skipped: 231 / Auto-skipped: 0


dynamic_domains_mysql_redis_24 / mysql_redis / 2e93602
Reports root/ big
OK: 2673 / Failed: 0 / User-skipped: 248 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 2e93602
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 2e93602
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 2e93602
Reports root/ big
OK: 2690 / Failed: 0 / User-skipped: 231 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 2e93602
Reports root/ big
OK: 1541 / Failed: 0 / User-skipped: 349 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 2e93602
Reports root/ big
OK: 3077 / Failed: 0 / User-skipped: 240 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 2e93602
Reports root/ big
OK: 3077 / Failed: 0 / User-skipped: 240 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 2e93602
Reports root/ big
OK: 1834 / Failed: 0 / User-skipped: 361 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 2e93602
Reports root/ big
OK: 3072 / Failed: 0 / User-skipped: 245 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 2e93602
Reports root/ big
OK: 1680 / Failed: 0 / User-skipped: 362 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 2e93602
Reports root/ big
OK: 3082 / Failed: 1 / User-skipped: 240 / Auto-skipped: 0

muc_SUITE:register:user_submits_registration_form_twice
{error,
  {{assertion_failed,assert,is_iq_result,
     [{xmlel,<<"iq">>,
        [{<<"type">>,<<"set">>},
         {<<"id">>,<<"8a4e5172635329f75bb2c70ab115d7bd">>},
         {<<"to">>,<<"muc.localhost">>}],
        [{xmlel,<<"query">>,
           [{<<"xmlns">>,<<"jabber:iq:register">>}],
           [{xmlel,<<"x">>,
            [{<<"xmlns">>,<<"jabber:x:data">>},
             {<<"type">>,<<"submit">>}],
            [{xmlel,<<"field">>,
               [{<<"type">>,<<"hidden">>},
                {<<"var">>,<<"FORM_TYPE">>}],
               [{xmlel,<<"value">>,[],
                  [{xmlcdata,<<"jabber:iq:register">>}]}]},
             {xmlel,<<"field">>,
               [{<<"type">>,<<"text-single">>},
                {<<"var">>,<<"nick">>}],
               [{xmlel,<<"value">>,[],
                  [{xmlcdata,
                     <<"thirdwitchroom-67a5afa352">>}]}]}]}]}]}],
     {xmlel,<<"iq">>,
       [{<<"from">>,<<"muc.localhost">>},
        {<<"to">>,
         <<"alicE_user_submits_registration_form_twice_1909@localhost/res1">>},
        {<<"type">>,<<"error">>},
        {<<"xml:lang">>,<<"en">>},
        {<<"id">>,<<"8a4e5172635329f75bb2c70ab115d7bd">>}],
       [{xmlel,<<"query">>,
          [{<<"xmlns">>,<<"jabber:iq:register">>}],
          [{xmlel,<<"x">>,
             [{<<"xmlns">>,<<"jabber:x:data">>},
            {<<"type">>,<<"submit">>}],
             [{xmlel,<<"field">>,
              [{<<"type">>,<<"hidden">>},
               {<<"var">>,<<"FORM_TYPE">>}],
      ...

Report log

@chrzaszcz chrzaszcz marked this pull request as ready for review January 12, 2022 08:24
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 only have two comments that are honestly nothing more than wishful perfectionism, this code is fantastic as it is and can be merged, I just wanted to raise some thoughts 😄

src/mongoose_listener_config.erl Outdated Show resolved Hide resolved
src/ejabberd_listener.erl Outdated Show resolved Hide resolved
@mongoose-im
Copy link
Collaborator

mongoose-im commented Jan 12, 2022

small_tests_24 / small_tests / 80c2195
Reports root / small


small_tests_23 / small_tests / 80c2195
Reports root / small


dynamic_domains_mysql_redis_24 / mysql_redis / 80c2195
Reports root/ big
OK: 2673 / Failed: 0 / User-skipped: 248 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 80c2195
Reports root/ big
OK: 2690 / Failed: 0 / User-skipped: 231 / Auto-skipped: 0


dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 80c2195
Reports root/ big
OK: 2690 / Failed: 0 / User-skipped: 231 / Auto-skipped: 0


dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 80c2195
Reports root/ big
OK: 2690 / Failed: 0 / User-skipped: 231 / Auto-skipped: 0


ldap_mnesia_24 / ldap_mnesia / 80c2195
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


ldap_mnesia_23 / ldap_mnesia / 80c2195
Reports root/ big
OK: 1500 / Failed: 0 / User-skipped: 390 / Auto-skipped: 0


internal_mnesia_24 / internal_mnesia / 80c2195
Reports root/ big
OK: 1541 / Failed: 0 / User-skipped: 349 / Auto-skipped: 0


pgsql_mnesia_23 / pgsql_mnesia / 80c2195
Reports root/ big
OK: 3077 / Failed: 0 / User-skipped: 240 / Auto-skipped: 0


pgsql_mnesia_24 / pgsql_mnesia / 80c2195
Reports root/ big
OK: 3077 / Failed: 0 / User-skipped: 240 / Auto-skipped: 0


elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 80c2195
Reports root/ big
OK: 1834 / Failed: 0 / User-skipped: 361 / Auto-skipped: 0


mssql_mnesia_24 / odbc_mssql_mnesia / 80c2195
Reports root/ big
OK: 3077 / Failed: 0 / User-skipped: 240 / Auto-skipped: 0


mysql_redis_24 / mysql_redis / 80c2195
Reports root/ big
OK: 3072 / Failed: 0 / User-skipped: 245 / Auto-skipped: 0


riak_mnesia_24 / riak_mnesia / 80c2195
Reports root/ big
OK: 1680 / Failed: 0 / User-skipped: 362 / Auto-skipped: 0

@NelsonVides NelsonVides merged commit b9b34c2 into master Jan 12, 2022
@NelsonVides NelsonVides deleted the listener-config-map branch January 12, 2022 14:13
@Premwoik Premwoik added this to the 5.1.0 milestone May 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants