Merge pull request #12525 from zmstone/0216-docs-add-ref-to-bridge_mode

docs: add a reference to the origin of is_bridge and bridge_mode
This commit is contained in:
Zaiming (Stone) Shi 2024-02-16 15:32:52 +01:00 committed by GitHub
commit 9ffda0187f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 2 deletions

View File

@ -1551,6 +1551,8 @@ set_username(
set_username(_ConnPkt, ClientInfo) ->
{ok, ClientInfo}.
%% The `is_bridge` bit flag in CONNECT packet (parsed as `bridge_mode`)
%% is invented by mosquitto, named 'try_private': https://mosquitto.org/man/mosquitto-conf-5.html
set_bridge_mode(#mqtt_packet_connect{is_bridge = true}, ClientInfo) ->
{ok, ClientInfo#{is_bridge => true}};
set_bridge_mode(_ConnPkt, _ClientInfo) ->

View File

@ -675,9 +675,19 @@ merge_to_override_config(RawConf, Opts) ->
maps:merge(UpgradedOldConf, RawConf).
upgrade_conf(Conf) ->
ConfigLoader = emqx_app:get_config_loader(),
%% ensure module loaded
_ = ConfigLoader:module_info(),
case erlang:function_exported(ConfigLoader, schema_module, 0) of
true ->
try_upgrade_conf(apply(ConfigLoader, schema_module, []), Conf);
false ->
%% this happens during emqx app standalone test
Conf
end.
try_upgrade_conf(SchemaModule, Conf) ->
try
ConfLoader = emqx_app:get_config_loader(),
SchemaModule = apply(ConfLoader, schema_module, []),
apply(SchemaModule, upgrade_raw_conf, [Conf])
catch
ErrorType:Reason:Stack ->

View File

@ -301,6 +301,7 @@ parse_connect2(
proto_name = ProtoName,
proto_ver = ProtoVer,
%% For bridge mode, non-standard implementation
%% Invented by mosquitto, named 'try_private': https://mosquitto.org/man/mosquitto-conf-5.html
is_bridge = (BridgeTag =:= 8),
clean_start = bool(CleanStart),
will_flag = bool(WillFlag),
@ -772,6 +773,7 @@ serialize_variable(
proto_name = ProtoName,
proto_ver = ProtoVer,
%% For bridge mode, non-standard implementation
%% Invented by mosquitto, named 'try_private': https://mosquitto.org/man/mosquitto-conf-5.html
is_bridge = IsBridge,
clean_start = CleanStart,
will_flag = WillFlag,