**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.**

-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4091
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/4...@github.com>
_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to