Merge pull request #6277 from tigercl/fix/mongo-connector

fix(connector): fix options handling for mongo connector
This commit is contained in:
tigercl 2021-11-23 20:50:47 +08:00 committed by GitHub
commit 060962700e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 8 deletions

View File

@ -1163,7 +1163,7 @@ client_ssl_opts_schema(Defaults) ->
common_ssl_opts_schema(Defaults) ++
[ { "server_name_indication",
sc(hoconsc:union([disable, string()]),
#{ default => disable
#{ nullable => true
, desc =>
"""Specify the host name to be used in TLS Server Name Indication extension.<br>
For instance, when connecting to \"server.example.net\", the genuine server

View File

@ -105,7 +105,7 @@ on_start(InstId, Config = #{mongo_type := Type,
sharded -> "starting_mongodb_sharded_connector"
end,
?SLOG(info, #{msg => Msg, connector => InstId, config => Config}),
NConfig = may_parse_srv_and_txt_records(Config),
NConfig = #{hosts := Hosts} = may_parse_srv_and_txt_records(Config),
SslOpts = case maps:get(enable, SSL) of
true ->
[{ssl, true},
@ -119,6 +119,7 @@ on_start(InstId, Config = #{mongo_type := Type,
end,
Topology = maps:get(topology, NConfig, #{}),
Opts = [{type, init_type(NConfig)},
{hosts, Hosts},
{pool_size, PoolSize},
{options, init_topology_options(maps:to_list(Topology), [])},
{worker_options, init_worker_options(maps:to_list(NConfig), SslOpts)}],
@ -193,9 +194,9 @@ mongo_query(Conn, find_one, Collection, Selector, Projector) ->
mongo_query(_Conn, _Action, _Collection, _Selector, _Projector) ->
ok.
init_type(#{type := rs, replica_set_name := ReplicaSetName}) ->
init_type(#{mongo_type := rs, replica_set_name := ReplicaSetName}) ->
{rs, ReplicaSetName};
init_type(#{type := Type}) ->
init_type(#{mongo_type := Type}) ->
Type.
init_topology_options([{pool_size, Val} | R], Acc) ->

View File

@ -73,10 +73,7 @@ save_files_return_opts(Options, Dir) ->
Key = do_save_file(KeyFile, Dir),
Cert = do_save_file(CertFile, Dir),
CA = do_save_file(CAFile, Dir),
Verify = case GetD(verify, false) of
false -> verify_none;
_ -> verify_peer
end,
Verify = GetD(verify, verify_none),
SNI = Get(server_name_indication),
Versions = emqx_tls_lib:integral_versions(Get(tls_versions)),
Ciphers = emqx_tls_lib:integral_ciphers(Versions, Get(ciphers)),
@ -92,6 +89,7 @@ save_file(Param, SubDir) ->
do_save_file(Param, Dir).
filter([]) -> [];
filter([{_, undefined} | T]) -> filter(T);
filter([{_, ""} | T]) -> filter(T);
filter([H | T]) -> [H | filter(T)].