Skip to content

Commit

Permalink
boot, setting: whitelist: try to resolve peer address
Browse files Browse the repository at this point in the history
This uses NRF.resolveAddress() on newer firmwares, to try to resolve "random private resolvable addresses" of peers that connect, before checking the whitelist.
  • Loading branch information
ssievert42 committed Aug 16, 2023
1 parent 656b8a2 commit 54711ba
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 4 deletions.
1 change: 1 addition & 0 deletions apps/boot/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,4 @@
0.56: Settings.log = 0,1,2,3 for off,display, log, both
0.57: Handle the whitelist being disabled
0.58: "Make Connectable" temporarily bypasses the whitelist
0.59: Whitelist: try to resolve peer addresses using NRF.resolveAddress() - for 2v19 or 2v18 cutting edge builds
2 changes: 1 addition & 1 deletion apps/boot/bootupdate.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ if (global.save) boot += `global.save = function() { throw new Error("You can't
if (s.options) boot+=`Bangle.setOptions(${E.toJS(s.options)});\n`;
if (s.brightness && s.brightness!=1) boot+=`Bangle.setLCDBrightness(${s.brightness});\n`;
if (s.passkey!==undefined && s.passkey.length==6) boot+=`NRF.setSecurity({passkey:${E.toJS(s.passkey.toString())}, mitm:1, display:1});\n`;
if (s.whitelist && !s.whitelist_disabled) boot+=`NRF.on('connect', function(addr) { if (!NRF.ignoreWhitelist && !(require('Storage').readJSON('setting.json',1)||{}).whitelist.includes(addr)) NRF.disconnect(); });\n`;
if (s.whitelist && !s.whitelist_disabled) boot+=`NRF.on('connect', function(addr) { if (!NRF.ignoreWhitelist) { let whitelist = (require('Storage').readJSON('setting.json',1)||{}).whitelist; if (NRF.resolveAddress !== undefined) { let resolvedAddr = NRF.resolveAddress(addr); if (resolvedAddr !== undefined) addr = resolvedAddr + " (resolved)"; } if (!whitelist.includes(addr)) NRF.disconnect(); }});\n`;
if (s.rotate) boot+=`g.setRotation(${s.rotate&3},${s.rotate>>2});\n` // screen rotation
// ================================================== FIXING OLDER FIRMWARES
if (FWVERSION<215.068) // 2v15.68 and before had compass heading inverted.
Expand Down
2 changes: 1 addition & 1 deletion apps/boot/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "boot",
"name": "Bootloader",
"version": "0.58",
"version": "0.59",
"description": "This is needed by Bangle.js to automatically load the clock, menu, widgets and settings",
"icon": "bootloader.png",
"type": "bootloader",
Expand Down
3 changes: 2 additions & 1 deletion apps/setting/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,5 @@ of 'Select Clock'
0.60: Moved LCD calibration to top of menu, and use 12 taps (not 8)
LCD calibration will now error if the calibration is obviously wrong
0.61: Permit temporary bypass of the BLE whitelist
0.62: Fix whitelist showing as 'on' by default when it's not after 0.59
0.62: Fix whitelist showing as 'on' by default when it's not after 0.59
0.63: Whitelist: try to resolve peer addresses using NRF.resolveAddress() - for 2v19 or 2v18 cutting edge builds
2 changes: 1 addition & 1 deletion apps/setting/metadata.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"id": "setting",
"name": "Settings",
"version": "0.62",
"version": "0.63",
"description": "A menu for setting up Bangle.js",
"icon": "settings.png",
"tags": "tool,system",
Expand Down
6 changes: 6 additions & 0 deletions apps/setting/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,6 +383,12 @@ function showWhitelistMenu() {
NRF.on('connect', function(addr) {
if (!settings.whitelist) settings.whitelist=[];
delete settings.whitelist_disabled;
if (NRF.resolveAddress !== undefined) {
let resolvedAddr = NRF.resolveAddress(addr);
if (resolvedAddr !== undefined) {
addr = resolvedAddr + " (resolved)";
}
}
settings.whitelist.push(addr);
updateSettings();
NRF.removeAllListeners('connect');
Expand Down

0 comments on commit 54711ba

Please sign in to comment.