Show the policy rule name in the drop reason (packet feed and packet history) #172

Open
opened 2026-10-27 09:36:09 +01:00 by adam · 0 comments
Owner

What happens now

When a policy rule drops a packet, the drop reason stored with the packet is Policy blocked packet (rule <id>) (_policy_drop_reason in repeater/engine.py). The packet feed and the packet history only show the rule's id, so to find out which rule stopped a packet you have to look the id up in the policy settings by hand. The rule's name is only written to the log (PolicyEngine.evaluate puts it in reason).

Request

Include the rule's name in the drop reason, for example Policy blocked packet (rule 12: spam campaign text). The Policy blocked packet prefix stays the same, so the dashboard's policy-event count (which matches on that prefix) keeps working. Because drop_reason is already stored in the packets table, the name would then show in both the live packet feed and the packet history, so a drop can still be looked up later.

A small way to do it: add an optional rule_name to PolicyDecision, set it in PolicyEngine.evaluate next to rule_id, and use it in _policy_drop_reason when present.

Why

Operators testing anti-spam rules (for example the SpamGuard plugin, which writes descriptive rule names such as (yours) text "..." or (duplicate)) want to see at a glance which rule dropped a packet and whether it was one they added themselves. This came up from testers in the Dutch MeshCore community, who asked for the rule name in the packet feed, and for it to be kept in the packet history so it can be searched afterwards.

Thanks for openHop!

**What happens now** When a policy rule drops a packet, the drop reason stored with the packet is `Policy blocked packet (rule <id>)` (`_policy_drop_reason` in `repeater/engine.py`). The packet feed and the packet history only show the rule's id, so to find out which rule stopped a packet you have to look the id up in the policy settings by hand. The rule's name is only written to the log (`PolicyEngine.evaluate` puts it in `reason`). **Request** Include the rule's name in the drop reason, for example `Policy blocked packet (rule 12: spam campaign text)`. The `Policy blocked packet` prefix stays the same, so the dashboard's policy-event count (which matches on that prefix) keeps working. Because `drop_reason` is already stored in the packets table, the name would then show in both the live packet feed and the packet history, so a drop can still be looked up later. A small way to do it: add an optional `rule_name` to `PolicyDecision`, set it in `PolicyEngine.evaluate` next to `rule_id`, and use it in `_policy_drop_reason` when present. **Why** Operators testing anti-spam rules (for example the SpamGuard plugin, which writes descriptive rule names such as `(yours) text "..."` or `(duplicate)`) want to see at a glance which rule dropped a packet and whether it was one they added themselves. This came up from testers in the Dutch MeshCore community, who asked for the rule name in the packet feed, and for it to be kept in the packet history so it can be searched afterwards. Thanks for openHop! <!-- github-sync-id:5869847194 -->
Sign in to join this conversation.
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: adam/pyMC_Repeater#172