**Description**
The `secfilter` module in `kamcmd` currently allows duplicate entries when adding values to certain lists (e.g., blacklists, whitelists). This can lead to unexpected behavior and potential inconsistencies. Could you clarify the reason behind accepting duplicate values?
Recently, I submitted a pull request to add delete commands to the `secfilter` module #4089. When a user, for example, executes:
`kamcmd secfilter.del_bl user 1005`
I iterate through the entire list to ensure all occurrences of `1005` are removed, as I realized duplicates might exist. This is inefficient and could be avoided by preventing duplicates in the first place.
**Proposed Solutions**
1. **Prevent Duplicates in Existing `add` Commands:** * I can modify existing `add` commands to directly prevent the addition of duplicate values. This would simplify future operations and improve performance.
2. **Introduce New `add_unique` Commands:** * I can maintain the current `add` commands for backward compatibility. * I can introduce new `add_unique` commands (e.g., `secfilter.add_bl_unique`) that explicitly reject duplicate entries.
**Recommendation**
I recommend implementing the first solution (preventing duplicates in existing `add` commands) as it provides the most straightforward and efficient approach.
**Further Considerations**
* Consider adding a check for duplicates during the `add` operation and returning an appropriate error message if a duplicate is encountered. * Document the behavior of duplicate values in the `secfilter` module's documentation.
**I would appreciate your feedback and guidance on the best course of action.**
I would be happy if you could give me feedback :) @miconda @henningw
github-actions[bot] left a comment (kamailio/kamailio#4091)
This issue is stale because it has been open 6 weeks with no activity. Remove stale label or comment or this will be closed in 2 weeks.
Closed #4091 as not planned.
Reopened #4091.