Skip to content

Commit

Permalink
changing format of hide_service_name option to local_config
Browse files Browse the repository at this point in the history
hide_service_name configuration for specific host type (previously for specific domain) make no sense,
since we don't know the domain name at the moment when we fetch the value of the option. in fact (before
introduction of the host types) we were always using the value for ?MYNAME host, which was the first
item in the 'hosts' list.
  • Loading branch information
DenysGonchar committed Apr 8, 2021
1 parent f146455 commit 0e069ca
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 11 deletions.
2 changes: 1 addition & 1 deletion big_tests/tests/connect_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ end_per_group(_, Config) ->
Config.

init_per_testcase(close_connection_if_service_type_is_hidden = CN, Config) ->
OptName = {hide_service_name, <<"localhost">>},
OptName = hide_service_name,
mongoose_helper:successful_rpc(ejabberd_config, add_local_option, [OptName, true]),
escalus:init_per_testcase(CN, Config);
init_per_testcase(replaced_session_cannot_terminate = CN, Config) ->
Expand Down
6 changes: 2 additions & 4 deletions doc/advanced-configuration/host_config.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,24 +30,22 @@ The following options are allowed:
* [`pgsql_users_number_estimate`](general.md#generalpgsql_users_number_estimate)
* [`route_subdomains`](general.md#generalroute_subdomains)
* [`replaced_wait_timeout`](general.md#generalreplaced_wait_timeout)
* [`hide_service_name`](general.md#generalhide_service_name)

#### Example

The `hide_service_name` option is set to `false` only for `domain2.com`.
The `replaced_wait_timeout` option is set to `2000` only for `domain2.com`.

```toml
[general]
hosts = ["domain1.com", "domain2.com", "domain3.com"]
loglevel = "info"
hide_service_name = true
replaced_wait_timeout = 1000

[[host_config]]
host = "domain2.com"

[host_config.general]
hide_service_name = false
replaced_wait_timeout = 2000
```

### `host_config.auth`
Expand Down
2 changes: 1 addition & 1 deletion src/config/mongoose_config_spec.erl
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ general() ->
validate = positive,
format = host_local_config},
<<"hide_service_name">> => #option{type = boolean,
format = host_local_config}
format = local_config}
},
format = none
}.
Expand Down
6 changes: 3 additions & 3 deletions test/config_parser_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,9 @@ replaced_wait_timeout(_Config) ->
err_host_config(#{<<"general">> => #{<<"replaced_wait_timeout">> => 0}}).

hide_service_name(_Config) ->
eq_host_config([#local_config{key = {hide_service_name, ?HOST}, value = false}],
#{<<"general">> => #{<<"hide_service_name">> => false}}),
err_host_config(#{<<"general">> => #{<<"hide_service_name">> => []}}).
compare_config([#local_config{key = hide_service_name, value = false}],
parse(#{<<"general">> => #{<<"hide_service_name">> => false}})),
?err(parse(#{<<"general">> => #{<<"hide_service_name">> => []}})).

%% tests: listen

Expand Down
3 changes: 1 addition & 2 deletions test/config_parser_SUITE_data/miscellaneous.options
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{config,default_server_domain,<<"localhost">>}.
{config,hosts,[<<"localhost">>,<<"anonymous.localhost">>]}.
{local_config,cowboy_server_name,"Apache"}.
{local_config,hide_service_name,true}.
{local_config,listen,
[{{5280,{0,0,0,0},tcp},
ejabberd_cowboy,
Expand Down Expand Up @@ -59,8 +60,6 @@
{bucket_type,<<"user_bucket">>}]}.
{local_config,{extauth_instances,<<"anonymous.localhost">>},1}.
{local_config,{extauth_instances,<<"localhost">>},1}.
{local_config,{hide_service_name,<<"anonymous.localhost">>},true}.
{local_config,{hide_service_name,<<"localhost">>},true}.
{local_config,{pgsql_users_number_estimate,<<"anonymous.localhost">>},true}.
{local_config,{pgsql_users_number_estimate,<<"localhost">>},true}.
{local_config,{replaced_wait_timeout,<<"anonymous.localhost">>},2000}.
Expand Down

0 comments on commit 0e069ca

Please sign in to comment.