Merge pull request #8979 from JimMoen/fix-mqtt-bridge-anonymous-client

fix(bridge): mqtt bridge client info `username` & `password`
This commit is contained in:
JimMoen 2022-09-16 16:06:01 +08:00 committed by GitHub
commit a48160eae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 16 deletions

View File

@ -222,20 +222,20 @@ make_forward_confs(undefined) ->
make_forward_confs(FrowardConf) -> make_forward_confs(FrowardConf) ->
FrowardConf. FrowardConf.
basic_config(#{ basic_config(
#{
server := Server, server := Server,
reconnect_interval := ReconnIntv, reconnect_interval := ReconnIntv,
proto_ver := ProtoVer, proto_ver := ProtoVer,
bridge_mode := BridgeMode, bridge_mode := BridgeMode,
username := User,
password := Password,
clean_start := CleanStart, clean_start := CleanStart,
keepalive := KeepAlive, keepalive := KeepAlive,
retry_interval := RetryIntv, retry_interval := RetryIntv,
max_inflight := MaxInflight, max_inflight := MaxInflight,
replayq := ReplayQ, replayq := ReplayQ,
ssl := #{enable := EnableSsl} = Ssl ssl := #{enable := EnableSsl} = Ssl
}) -> } = Conf
) ->
#{ #{
replayq => ReplayQ, replayq => ReplayQ,
%% connection opts %% connection opts
@ -251,8 +251,9 @@ basic_config(#{
%% non-standard mqtt connection packets will be filtered out by LB. %% non-standard mqtt connection packets will be filtered out by LB.
%% So let's disable bridge_mode. %% So let's disable bridge_mode.
bridge_mode => BridgeMode, bridge_mode => BridgeMode,
username => User, %% should be iolist for emqtt
password => Password, username => maps:get(username, Conf, <<>>),
password => maps:get(password, Conf, <<>>),
clean_start => CleanStart, clean_start => CleanStart,
keepalive => ms_to_s(KeepAlive), keepalive => ms_to_s(KeepAlive),
retry_interval => RetryIntv, retry_interval => RetryIntv,