Feature: let the web console move a host to another group
The Go server now keeps a per-device group override (device_groups.json) edited from the card's "..." menu below Edit remark. The override wins over the group the host reported (or the offline history record) in the device list, the group filter, get_groups and the MCP host tools, so offline records can be regrouped and the change survives restarts. An empty value clears the override; names are capped at 23 characters, matching the Win32 regroup dialog. The command is admin-only and honours the device ACL; it refuses IDs the server has never seen (online or in history) so a stale card cannot create an orphan entry, and the remark handler gets the same guard. Each change is audited as admin.device.group, deleting a device drops its override, and values loaded from disk are trimmed and capped like remarks. The menu entry is gated on the groupEdit capability, so the shared page hides it on the MFC server. Like remarks, the override is a Go-side label: no CMD_SET_GROUP is sent, so the host keeps reporting its own group to other masters. Verified with go test ./..., go vet, gofmt and a node --check pass on the page. Co-Authored-By: deepseek-flash
This commit is contained in:
1 parent
5f764b2425
commit
034b11fa6a
16 files changed
+895
-54
No files matched your search
@@ -1204,6 +1204,21 @@ func main() {
|
||||
log.Info("Device remarks loaded from %s (%d remark(s))", notesFile, len(deviceNotes.Snapshot()))
|
||||
}
|
||||
|
||||
// Per-device group overrides (the web console's "edit group") live next to
|
||||
// the remark table with the same fail-safe policy: a malformed file is
|
||||
// never overwritten and edits are refused until it is fixed.
|
||||
groupsFile := os.Getenv("YAMA_DEVICE_GROUPS_FILE")
|
||||
if groupsFile == "" {
|
||||
groupsFile = filepath.Join(filepath.Dir(usersFile), "device_groups.json")
|
||||
rememberDefault("YAMA_DEVICE_GROUPS_FILE", groupsFile)
|
||||
}
|
||||
deviceGroups := web.NewDeviceGroups(groupsFile)
|
||||
if err := deviceGroups.Load(); err != nil {
|
||||
log.Warn("Failed to load device groups from %s: %v (group edits are refused until the file is fixed)", groupsFile, err)
|
||||
} else {
|
||||
log.Info("Device groups loaded from %s (%d override(s))", groupsFile, len(deviceGroups.Snapshot()))
|
||||
}
|
||||
|
||||
// TCP authorization (TOKEN_AUTH) brute-force throttle. Keyed by source IP
|
||||
// (the real TCP peer — there is no X-Forwarded-For on the device port).
|
||||
// Generous enough that a NAT office whose devices all re-auth at once is
|
||||
@@ -1294,6 +1309,8 @@ func main() {
|
||||
DeviceACL: deviceACL,
|
||||
// Web-console remarks are returned by list_hosts/get_host_detail.
|
||||
DeviceRemarks: deviceNotes,
|
||||
// Web-console group overrides are applied to the group field/filter.
|
||||
DeviceGroups: deviceGroups,
|
||||
})
|
||||
if mcpSrv.Enabled() {
|
||||
// Terminal tools need the hub's shell events (ready/data/closed).
|
||||
@@ -1435,6 +1452,7 @@ func main() {
|
||||
SSO: ssoDetector,
|
||||
DeviceACL: deviceACL,
|
||||
DeviceNotes: deviceNotes,
|
||||
DeviceGroups: deviceGroups,
|
||||
TransferTarget: transferTarget,
|
||||
TransferDays: transferDays,
|
||||
TransferTransport: transferTransport,
|
||||
|
||||
Reference in new issue
Block a user