Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for time-base scheduling of blacklists #1428

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

laghoule
Copy link

@laghoule laghoule commented Apr 4, 2024

My use case:

I have created a blacklist URL of YouTube, and I want to create a schedule for when I want it to block access.

Example of config:

blocking:
  blackLists:
    youtube:
      - https://raw.githubusercontent.com/gieljnssns/Social-media-Blocklists/master/pihole-youtube.txt
  schedules:
    youtube:
      - days: ["Mon", "Tue", "Wed", "Thu"]
        hoursRanges:
          - "06:45-08:30"
          - "19:00-23:30"
      - days: ["Sun"]
        hoursRanges:
          - "20:00-23:30" 

So, I have implemented it, with updated doc, readme & unit-tests. It's working fine on my K8S cluster for 1 month.
Let me know what you think.

Thanks for the project.

@kwitsch
Copy link
Collaborator

kwitsch commented Apr 6, 2024

This looks interesting. 👍

A case I just thought about which could be problematic with the current implementation:

  • blocklist has schedule 8 to 17 o'clock
  • block TTL is set to 1 hour
  • temporary blocked URL is requested at 16.45
  • same URL(not blocked anymore) is requested at 16.15

Same applies the other way around(pre and post 8).

This is just a theoretical scenario since such huge TTLs aren't beneficial most of the time(I know some users configure such TTLs tho).
This scenario isn't limited to this change but also applies to disabling blocklists manually.

Best practice in my opinion would be to clear cache entries covered by newly enabled/disabled blocklists.

@laghoule
Copy link
Author

laghoule commented Apr 6, 2024

@kwitsch Thanks for your feedback, I will look into it.

Copy link

codecov bot commented Apr 12, 2024

Codecov Report

Attention: Patch coverage is 83.44828% with 24 lines in your changes missing coverage. Please review.

Project coverage is 93.91%. Comparing base (fe84ab8) to head (05d579a).
Report is 87 commits behind head on main.

Current head 05d579a differs from pull request most recent head 899e005

Please upload reports for the commit 899e005 to get more accurate results.

Files Patch % Lines
resolver/blocking_resolver.go 7.69% 10 Missing and 2 partials ⚠️
config/schedules.go 85.18% 6 Missing and 2 partials ⚠️
config/schedule.go 93.93% 2 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1428      +/-   ##
==========================================
+ Coverage   93.88%   93.91%   +0.02%     
==========================================
  Files          78       80       +2     
  Lines        6361     5141    -1220     
==========================================
- Hits         5972     4828    -1144     
+ Misses        300      216      -84     
- Partials       89       97       +8     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@laghoule laghoule marked this pull request as draft April 23, 2024 15:07
@laghoule laghoule force-pushed the feature/schedule branch 2 times, most recently from ed0a544 to d6cf031 Compare May 26, 2024 00:15
This make to code more readable

Signed-off-by: Pascal Gauthier <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants