Fix retain in will message (#2607)
* Fix retain in will message * Only handle retain available flag in MQTT v5
This commit is contained in:
parent
f801ff1e53
commit
3462bbd619
|
@ -778,7 +778,8 @@ check_connect(Packet, PState) ->
|
||||||
fun check_client_id/2,
|
fun check_client_id/2,
|
||||||
fun check_flapping/2,
|
fun check_flapping/2,
|
||||||
fun check_banned/2,
|
fun check_banned/2,
|
||||||
fun check_will_topic/2], Packet, PState).
|
fun check_will_topic/2,
|
||||||
|
fun check_will_retain/2], Packet, PState).
|
||||||
|
|
||||||
check_proto_ver(#mqtt_packet_connect{proto_ver = Ver,
|
check_proto_ver(#mqtt_packet_connect{proto_ver = Ver,
|
||||||
proto_name = Name}, _PState) ->
|
proto_name = Name}, _PState) ->
|
||||||
|
@ -829,6 +830,16 @@ check_will_topic(#mqtt_packet_connect{will_topic = WillTopic} = ConnPkt, PState)
|
||||||
{error, ?RC_TOPIC_NAME_INVALID}
|
{error, ?RC_TOPIC_NAME_INVALID}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
check_will_retain(#mqtt_packet_connect{will_retain = false, proto_ver = ?MQTT_PROTO_V5}, _PState) ->
|
||||||
|
ok;
|
||||||
|
check_will_retain(#mqtt_packet_connect{will_retain = true, proto_ver = ?MQTT_PROTO_V5}, #pstate{zone = Zone}) ->
|
||||||
|
case emqx_zone:get_env(Zone, mqtt_retain_available, true) of
|
||||||
|
true -> {error, ?RC_RETAIN_NOT_SUPPORTED};
|
||||||
|
false -> ok
|
||||||
|
end;
|
||||||
|
check_will_retain(_Packet, _PState) ->
|
||||||
|
ok.
|
||||||
|
|
||||||
check_will_acl(#mqtt_packet_connect{will_topic = WillTopic},
|
check_will_acl(#mqtt_packet_connect{will_topic = WillTopic},
|
||||||
#pstate{zone = Zone, credentials = Credentials}) ->
|
#pstate{zone = Zone, credentials = Credentials}) ->
|
||||||
EnableAcl = emqx_zone:get_env(Zone, enable_acl, false),
|
EnableAcl = emqx_zone:get_env(Zone, enable_acl, false),
|
||||||
|
|
Loading…
Reference in New Issue