Repository navigation
feat: internet schedule (closes #32) - #47
Open
amr-elgharip2006 wants to merge 1 commit into
Open
amr-elgharip2006 wants to merge 1 commit into
amr-elgharip2006 wants to merge 1 commit into
Conversation
Turn the internet off at set times of the week for chosen people (all
their devices) or single devices: bedtime, study time, meal times.
- quota/schedules.py: pure time math. Windows per weekday, past-midnight
windows belong to the day they start, touching windows merge, skip
dates (holidays), bonus time (pause without editing), stored as JSON
in settings. A broken row is skipped, never fatal.
- quota/schedule_nft.py: its own table inet quota_schedule, never
flushed on service start. Devices are added with an nft timeout equal
to the end of their cut, so the kernel frees them on time even if the
service stops. Forward chain at priority -5 (dropped packets are not
counted), IPv4 + IPv6 + MAC, LAN excluded. Each change is one atomic
nft -f batch, cache-gated.
- Always-allowed sites: dnsmasq nftset= fills allow4/allow6 through the
existing DnsRuleManager validation and rollback path.
- Tick step 4 programs the table; API edits apply at once. Devices off
by schedule are also denied on network drives.
- API: /api/schedules (CRUD), /api/schedules/{id}/pause, /api/schedule-sites;
/api/dashboard reports when each device's internet comes back.
- Dashboard: new "Internet schedule" page (presets, weekly timeline,
bonus time, days off, allowed sites), status chip on people, banner in
the device drawer, Arabic + English.
- Tests: tests/test_schedules.py (31) + API test. Docs updated.
Owner
|
Thanks a lot for these. We're shipping the Netrex rename (0.5.11) first and will review them right after it, starting with the smaller fixes. The repository is now |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #32.
Turn the internet off at set times of the week for chosen people (all their devices) or single devices: bedtime on school nights, study time, meal times.
What the admin gets
How it is enforced
quota/schedules.pyis pure time math: windows per weekday, past-midnight windows belong to the day they start, touching windows are merged so the real end is shown, plus days off and bonus time. Schedules are stored as JSON insettings, and a broken row is skipped instead of stopping the others.quota/schedule_nft.pyadds its own table,inet quota_schedule. It is never flushed on service start, so a device stays off while the service restarts.quota_gateway's counters, so dropped packets are not counted as usage.nft -f -batch (flush and re-add together), cache-gated on (address, end time). There is no unblock window and no nft call when nothing changed.nftset=to fillallow4/allow6. The fragment goes through the existingDnsRuleManagerpath, sodnsmasq --testand the rollback still apply.API
GET/POST /api/schedules,PUT/DELETE /api/schedules/{id}POST /api/schedules/{id}/pause{minutes: 0..1440}PUT /api/schedule-sites{sites: [...]}/api/dashboardaddsschedule: {until_ts, names}per device and per person.Tests
tests/test_schedules.py(31 tests) covers:nftsetfragmenttest_updater.py::test_auto_install_fires_after_check, which fails onmaintoo.Tested on a real gateway
I tested this on a real gateway: Debian 12 arm64, kernel 6.1, nftables 1.0.6, dnsmasq 2.90 (built with nftset), PPPoE WAN.
allow4)The changes are listed under
[Unreleased]in the CHANGELOG, andquota/version.pyis not changed.