Allow inline # comments in whitelist and blacklist import lists. Allow importing IPs and not just CIDR - #192
Allow inline # comments in whitelist and blacklist import lists. Allow importing IPs and not just CIDR#192p1r473 wants to merge 18 commits into
Conversation
|
@p1r473 you have to be careful here with how much you are proposing to change. part of skynet relies heavy on skynet blocked ranges which relies on CIDR notation specifically ranges that are greater than /32. It takes those sets and imports them into separate ipsets specifically configured for handling netsets versus ipsets which is better on ram memory resources. Understand that you cannot just propose a pull request putting in your specifications that could potentially break the nature of this capability. Skynet does allow individual IP addresses into a separate pool but you need to notate with /32 like typical ipset/netset lists do. |
|
It is really up to @Adamm00 , but it is pretty much a corner stone feature for how the ipsets, netsets, and the stats and what not are set up. There is something bound to break down the line like a trickle down effect. I one time sent a major pull request to repair the features so I have first hand account of how the down hill impact works with changes to these parts of the code. Here is what I mean with my deep adventures into the skynet abyss. https://github.com/jumpsmm7/IPSet_ASUS/compare/4c8dbd706c8e04a77e0c3962495204884af0c7f7...d19c538acf85a8b2d11eae2cce475fa3d94f559d |
|
Thank you for your responses and wisdom, I will wait for Adam and I am happy to remove support for the non-CIDR (I can easily just put /32 in my whitelist on individual IPs) but would love at least for the inline comments and bigger blacklist to be approved 🙏🏻✌🏻 |
I definitely agree with you about the bigger blocklists. As everybody moves to the newer routers it may be more feasable. Maybe we should place a router model check in place for older generation routers versus newer generation routers so older gen get the lesser value, and newer gen get the higher value. [ -z "$(nvram get odmpid)" ] && ROUTER_MODEL="$(nvram get productid)" || ROUTER_MODEL="$(nvram get odmpid)" eg. ROUTER_ARCH="$(uname -m)" then it will become "$((65536 * BLK_VALUE))" |
|
I used AI to help review the relevant firewall paths, so please take with a grain of salt I double checked the import behavior, and I do not think this PR makes the import path less optimized. For whitelist imports, bare IPs are not left as bare entries. The PR appends if(ip~/^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$/) ip=ip"/32";So: is restored as: For blacklist imports, the existing split remains intact. Bare IPs and So the behavior remains: The PR is not trying to collapse netsets into ipsets or change Skynet’s range optimization model. It only makes imports more forgiving by allowing inline comments and bare host IPs, while preserving the existing host-vs-range handling. CC @jumpsmm7 |
grep -E '^(((25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9]).){3}(25[0-5]|(2[0-4]|1[0-9]|[1-9]|)[0-9]))$' which allows any IP without considering the CIDR Specifically Filter_IP() { By you adding a regex into the awk command you would be only slowing down the processing of the list with no real advantage that isn't already covered. |
|
Thanks, let me see if I can optimize |
|
@p1r473 |
Added dos2unix command to ensure proper line endings for the IP list.
|
@jumpsmm7 Thanks, I took another stab at updating the PR based on your feedback. I also found one issue in the suggested awk example: if(ip~/reg/)That matches the literal text if(ip ~ reg) |
|
@Adamm00 fyi! for your review. thank you! |
The current firewall import whitelist and firewall import blacklist logic only accepts lines that are only a CIDR.
Any line with a trailing inline comment or no CIDR range is silently discarded.
Example entries that fail silently today:
This leads to:
Import reporting success
Entries appearing partially imported
Some expected CIDRs missing from the active ipset
Traffic still being blocked unexpectedly
Root Cause
Import logic uses a strict anchored regex:
^...$
This requires the entire line to match an IP/CIDR and does not tolerate trailing content such as comments.
Solution
Strip inline comments and blank lines before validation.
This:
Behavior After Change
These entries now import correctly:
Entries appear in whitelist view imported
Entries populate the active ipset
Matching traffic is no longer blocked
Notes: the whitelist I am importing is my own here https://github.com/p1r473/ipblocklist/blob/main/ipwhitelist.txt