known-devices: add Device Groups management (add/edit/delete, multi-group) - #156
Merged
Conversation
…roup) A group has always been purely implicit -- just a name string repeated on each devices group= field -- so there was no way to create one before assigning a device to it, rename one across every device that carries it, or delete one without editing devices by hand. A device could also only ever belong to one group at a time. known_devices.sh gains a config group section type (declared, persists at zero devices) and multi-value list group membership. get_all_groups() unions device-derived names with declared ones. get_device_groups() reads via uci show rather than uci get: a list option with multiple values renders as one space-separated, individually-quoted line there, not one line per value -- verified live, not assumed. post_lease.sh now loops every group a matched MAC belongs to instead of stopping at the first, so a multi-group devices lease events update all of its nftables sets. manage_groups.sh/post_lease.sh set-management logic needed no other changes -- traced the ifup_firewall() call order and confirmed nftables set creation already precedes rule insertion regardless of device count. New Devices-page panel: add a group (name only), edit (renames it on every device carrying it, or just the declaration if zero-device), delete (clears the group from affected devices after confirming the count, never deletes the devices). The Add/Edit Device modal gets a checkbox per existing group (real multi-select) plus a separate add-new field; a name that matches an existing group by case or whitespace joins that group instead of creating a near-duplicate. Also folds five copies of an identical knownDeviceGroups shell one-liner (restriction.sh, dhcp.sh, quotas.sh, qos_upload.sh, qos_download.sh) into calls to the one shared library function they were all reimplementing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
group=field — so there was no way to declare one before assigning a device to it, rename one across every device that carried it, or delete one without editing devices by hand. A device could also only ever belong to one group at a time.known_devices.shgains aconfig groupsection type (declared, persists at zero devices) and multi-valuelist groupmembership.get_all_groups()unions device-derived names with declared ones.get_device_groups()reads viauci showrather thanuci get: alistoption with multiple values renders as one space-separated, individually-quoted line there, not one line per value — verified live on real hardware, not assumed.post_lease.shnow loops every group a matched MAC belongs to instead of stopping at the first, so a multi-group device's lease events update all of its nftables sets.manage_groups.shneeded no changes — traced theifup_firewall()call order and confirmed nftables set creation already precedes rule insertion regardless of device count.knownDeviceGroupsshell one-liner (restriction.sh,dhcp.sh,quotas.sh,qos_upload.sh,qos_download.sh) into calls to the one shared library function they were all reimplementing.Test plan
manage_groups.shcreates its set before any rule can reference it, confirmed cleanup removes it; a device in two groups correctly seeded into both nftables sets and kept correct on liveadd/delpost_lease.shevents