fix(channel): add warning log if the acl check of a subscribed topic failed
This commit is contained in:
parent
505507139e
commit
48d8f7e7a9
|
@ -1501,12 +1501,15 @@ check_pub_caps(#mqtt_packet{header = #mqtt_packet_header{qos = QoS,
|
||||||
check_sub_acls(TopicFilters, Channel) ->
|
check_sub_acls(TopicFilters, Channel) ->
|
||||||
check_sub_acls(TopicFilters, Channel, []).
|
check_sub_acls(TopicFilters, Channel, []).
|
||||||
|
|
||||||
check_sub_acls([ TopicFilter = {Topic, _} | More] , Channel, Acc) ->
|
check_sub_acls([ TopicFilter = {Topic, SubOpts} | More] , Channel, Acc) ->
|
||||||
case check_sub_acl(Topic, Channel) of
|
case check_sub_acl(Topic, Channel) of
|
||||||
allow ->
|
allow ->
|
||||||
check_sub_acls(More, Channel, [ {TopicFilter, 0} | Acc]);
|
check_sub_acls(More, Channel, [ {TopicFilter, 0} | Acc]);
|
||||||
deny ->
|
deny ->
|
||||||
check_sub_acls(More, Channel, [ {TopicFilter, ?RC_NOT_AUTHORIZED} | Acc])
|
ReasonCode = ?RC_NOT_AUTHORIZED,
|
||||||
|
?LOG(warning, "Cannot subscribe ~s with options ~p due to ~s.",
|
||||||
|
[Topic, SubOpts, emqx_reason_codes:text(ReasonCode)]),
|
||||||
|
check_sub_acls(More, Channel, [ {TopicFilter, ReasonCode} | Acc])
|
||||||
end;
|
end;
|
||||||
check_sub_acls([], _Channel, Acc) ->
|
check_sub_acls([], _Channel, Acc) ->
|
||||||
lists:reverse(Acc).
|
lists:reverse(Acc).
|
||||||
|
|
Loading…
Reference in New Issue