00_MQTT2_SERVER.pm: accept clients with empty clientId (Forum #90145)

git-svn-id: https://svn.fhem.de/fhem/trunk/fhem@17163 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
rudolfkoenig 2018-08-18 14:54:09 +00:00
parent ee414f557b
commit 6bc45d6426
2 changed files with 8 additions and 7 deletions

View File

@ -221,11 +221,12 @@ MQTT2_SERVER_Read($@)
my $cpt = $cptype{$cp}; my $cpt = $cptype{$cp};
$hash->{lastMsgTime} = gettimeofday(); $hash->{lastMsgTime} = gettimeofday();
#my $pltxt = $pl; # Lowlevel debugging
#$pltxt =~ s/[^ -~]/./g; # my $pltxt = $pl;
#Log3 $sname, 5, "$pltxt"; # $pltxt =~ s/([^ -~])/"(".ord($1).")"/ge;
# Log3 $sname, 5, "$pltxt";
if(!$hash->{cid} && $cpt ne "CONNECT") { if(!defined($hash->{cid}) && $cpt ne "CONNECT") {
Log3 $sname, 2, "$cname $cpt before CONNECT, disconnecting"; Log3 $sname, 2, "$cname $cpt before CONNECT, disconnecting";
CommandDelete(undef, $cname); CommandDelete(undef, $cname);
return MQTT2_SERVER_Read($hash, 1); return MQTT2_SERVER_Read($hash, 1);
@ -234,8 +235,8 @@ MQTT2_SERVER_Read($@)
#################################### ####################################
if($cpt eq "CONNECT") { if($cpt eq "CONNECT") {
($hash->{protoTxt}, $off) = MQTT2_SERVER_getStr($pl, 0); # V3:MQIsdb V4:MQTT ($hash->{protoTxt}, $off) = MQTT2_SERVER_getStr($pl, 0); # V3:MQIsdb V4:MQTT
$hash->{protoNum} = unpack('C*', substr($pl, $off++, 1)); $hash->{protoNum} = unpack('C*', substr($pl,$off++,1)); # 3 or 4
$hash->{cflags} = unpack('C*', substr($pl, $off++, 1)); $hash->{cflags} = unpack('C*', substr($pl,$off++,1));
$hash->{keepalive} = unpack('n', substr($pl, $off, 2)); $off += 2; $hash->{keepalive} = unpack('n', substr($pl, $off, 2)); $off += 2;
($hash->{cid}, $off) = MQTT2_SERVER_getStr($pl, $off); ($hash->{cid}, $off) = MQTT2_SERVER_getStr($pl, $off);

View File

@ -126,7 +126,7 @@ MQTT2_DEVICE_Parse($$)
# autocreate and expand readingList # autocreate and expand readingList
if($autocreate && !%fnd) { if($autocreate && !%fnd) {
return "" if($cid =~ m/mosqpub.*/); return "" if($cid && $cid =~ m/mosqpub.*/);
my $cidHash = $modules{MQTT2_DEVICE}{defptr}{cid}{$cid}; my $cidHash = $modules{MQTT2_DEVICE}{defptr}{cid}{$cid};
my $nn = $cidHash ? $cidHash->{NAME} : "MQTT2_$cid"; my $nn = $cidHash ? $cidHash->{NAME} : "MQTT2_$cid";
PrioQueue_add(sub{ PrioQueue_add(sub{