-
Notifications
You must be signed in to change notification settings - Fork 221
Block Range Test usage on unsecured/public primary channel #966
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Imported Protobuf in RangeTest.tsx to inspect channel PSK data.
Pulled channels and activeNode from useDevice() to evaluate the primary channel state.
Added logic to detect public/unsecured channels based on PSK length (0 or 1 bytes).
Disabled the entire <DynamicForm> UI via isDisabled={isPrimaryChannelPublic}.
Forced enabled = false inside both defaultValues and live values to fully prevent enabling Range Test, even via state manipulation.
Ensures all platforms (Android, iOS, Web) consistently prevent Range Test usage on public channels.
|
@dubsector is attempting to deploy a commit to the Meshtastic Team on Vercel. A member of the Team first needs to authorize it. |
|
Apologies in advance this is really my first pull request of this caliber. |
| const hexLen = pskBytes instanceof Uint8Array ? pskBytes.length : 0; | ||
| // Treat very short/absent keys as effectively "public"/unencrypted. | ||
| return hexLen === 0 || hexLen === 1; | ||
| })(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, wanted to understand why an IIFE was used here though, maybe I'm missing something about how this is designed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, how does this channel custom channels 0-9?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only treat Range Test as blocked when channel 0 is effectively “public” (no PSK or a 1-byte PSK). Additional custom channels (1–9) are untouched by this check, and Range Test isn’t gated on them here.
I originally used an IIFE here to keep the logic self-contained and allow early returns without needing a mutable variable. I did pull requests for web, android, and apple, so i was trying to keep the code consistent.
Could switch this to a local helper function. Let me know and I can update it.
const isChannelPublic = (channel?: Protobuf.Channel.Channel): boolean => {
if (!channel) return false;
const pskBytes = channel.settings?.psk;
const hexLen = pskBytes instanceof Uint8Array ? pskBytes.length : 0;
// Treat very short/absent keys as effectively "public"/unencrypted.
return hexLen === 0 || hexLen === 1;
};
const primaryChannel = channels.get(0 as Protobuf.Types.ChannelNumber);
const isPrimaryChannelPublic = isChannelPublic(primaryChannel);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, yeah I dont think we use IIFE's anywhere else in the web code base. So lets switch to an arrow function wrapped with "useCallback" to make sure its reference is stable during rendering.
danditomaso
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, just one comment to respond to and we can get this approved.
…nction Removed the inline IIFE used for computing isPrimaryChannelPublic Added a small useCallback helper (isChannelPublic) for reference stability during rendering Behavior remains identical: primary channel is treated as “public” when PSK length is 0–1 bytes No other logic or form behavior changed
dubsector
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I have updated it.
|
Looks good, thanks for contributing! |
|
It looks like a couple of lint errors are preventing this from being merged. Our lint rules prevent inline block statements, so once that is fixed we can get this merged. |
Imported Protobuf in RangeTest.tsx to inspect channel PSK data.
Pulled channels and activeNode from useDevice() to evaluate the primary channel state.
Added logic to detect public/unsecured channels based on PSK length (0 or 1 bytes).
Disabled the entire UI via isDisabled={isPrimaryChannelPublic}.
Forced enabled = false inside both defaultValues and live values to fully prevent enabling Range Test, even via state manipulation.
Ensures all platforms (Android, iOS, Web) consistently prevent Range Test usage on public channels.
Description
Related Issues
Changes Made
Testing Done
Screenshots (if applicable)
Checklist
CONTRIBUTING_I18N_DEVELOPER_GUIDE.md for more details)