Skip to content

Commit

Permalink
Fix acceptDevIncoming. Koenkk#538
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Apr 1, 2019
1 parent 78d9123 commit 50beb67
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions lib/zigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,23 +103,12 @@ class Zigbee {
`Accept device incoming with ieeeAddr '${devInfo.ieeeAddr}' permit join is '${this.getPermitJoin()}'`
);

if (this.getPermitJoin()) {
if (settings.get().ban.includes(devInfo.ieeeAddr)) {
logger.info(`Banned device tried to connect (${devInfo.ieeeAddr})`);
callback(null, false);
} else {
logger.debug(`Allowing device '${devInfo.ieeeAddr}' to join`);
callback(null, true);
}
if (settings.get().ban.includes(devInfo.ieeeAddr)) {
logger.info(`Banned device tried to connect (${devInfo.ieeeAddr})`);
callback(null, false);
} else {
if (this.getAllClients().find((d) => d.ieeeAddr === devInfo.ieeeAddr)) {
// Allow already connected devices to rejoin.
logger.debug(`Allowing device '${devInfo.ieeeAddr}' to join (already connected device)`);
callback(null, true);
} else {
logger.debug(`Not allowing '${devInfo.ieeeAddr}' to join`);
callback(null, false);
}
logger.debug(`Allowing device '${devInfo.ieeeAddr}' to join`);
callback(null, true);
}
}

Expand Down

0 comments on commit 50beb67

Please sign in to comment.