Skip to content

Commit

Permalink
Add extra acceptDevIncoming logging. Koenkk#538
Browse files Browse the repository at this point in the history
  • Loading branch information
Koenkk committed Mar 30, 2019
1 parent cdfc3ff commit 96b30d4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/zigbee.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,25 @@ class Zigbee {
}

_acceptDevIncoming(devInfo, callback) {
logger.debug(
`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);
}
} 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);
}
}
Expand Down

0 comments on commit 96b30d4

Please sign in to comment.