{"id":652,"date":"2026-11-29T16:11:00","date_gmt":"2026-11-30T00:11:00","guid":{"rendered":"https:\/\/blog.canutethegreat.com\/?p=652"},"modified":"2026-11-23T01:31:48","modified_gmt":"2026-11-23T09:31:48","slug":"patronus-a-time-limit-on-one-device-and-the-browser-tab-that-stayed-stuck","status":"publish","type":"post","link":"https:\/\/blog.canutethegreat.com\/index.php\/2026\/11\/29\/patronus-a-time-limit-on-one-device-and-the-browser-tab-that-stayed-stuck\/","title":{"rendered":"Patronus: a time limit on one device, and the browser tab that stayed stuck"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Full disclosure: I make Patronus, a router and firewall OS built on Gentoo. It&#8217;s young. Version 0.2.0 came out on October 30.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Most of what I write about it comes out of CI logs, and a green netlab run tells you very little about what a feature is like to use. So on November 8 I took one 0.2.0 feature, per-device time limits, and used it the way a parent would. I set a policy, pushed traffic through the router from a pretend tablet, watched the tablet get cut off, and pressed the buttons.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What this setup is<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It&#8217;s a lab, not my house. One container with four network namespaces: the router (the real <code>patronus-web<\/code> and <code>patronus apply<\/code> built from main, commit 9f5b2361), a LAN client I called kids-tablet, a fake ISP, and a fake internet that uses documentation addresses and <code>*.example.test<\/code> names. The browser on the &#8220;tablet&#8221; runs inside the client namespace, so every page it loads really crosses the router.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The clock is the one fake part. I moved the router&#8217;s time with <code>PATRONUS_FAKE_TIME_FILE<\/code>, the knob the tests use, so an evening took half a minute. Bytes, conntrack counters, nft sets and the pages are real. The passing of time isn&#8217;t, so this covers one quota day and a few next-day checks, not a month of living with it. That&#8217;s also why the screenshots say 2026-11-09.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">The policy<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">120 minutes a day, only between 16:00 and 20:00, a warning 5 minutes before the cut, the day resetting at 06:00, attached to a group called kids. kids-tablet is the only device in that group.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-time-limits-page-1.webp\" alt=\"Time limits page: kids-tablet has used 45 of 120 minutes, with buttons to add 30 minutes or pause the internet, above a policy of 120 minutes a day between 16:00 and 20:00 applied to the kids group\" loading=\"lazy\"\/><figcaption class=\"wp-element-caption\">The Time limits page under Segmentation. The policy table is at the bottom.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">A minute only counts if the device moved more than a byte threshold in it (20000 bytes by default, taken from conntrack counters). The docs say the point is that a tablet sitting idle doesn&#8217;t use up the day. Minutes spent blocked don&#8217;t count either: the tablet sat at 120 of 120 while I reloaded the blocked page over and over.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-usage-46-of-120-1.webp\" alt=\"Green usage bar at 46 of 120 minutes, state online ok\" loading=\"lazy\"\/><figcaption class=\"wp-element-caption\">46 of 120, after real traffic through the router.<\/figcaption><\/figure>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-usage-115-of-120-warning-1.webp\" alt=\"Amber usage bar at 115 of 120 minutes, state ending soon\" loading=\"lazy\"\/><figcaption class=\"wp-element-caption\">115 of 120. This is where the warning fires.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">At 115 the tablet&#8217;s next plain http page was replaced by a &#8220;5 minutes left&#8221; notice. That&#8217;s a one-shot redirect that lasts two minutes.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-tablet-5-minutes-left-1.webp\" alt=\"Warning page on the tablet: 5 minutes left\" loading=\"lazy\"\/><figcaption class=\"wp-element-caption\">What the tablet shows.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">The clip<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">This is the tablet&#8217;s browser on the left and the router&#8217;s admin page on the right, recorded in one take with no cuts and no speed changes. I added the labels and captions afterwards. The 118 minutes of usage before the clip came from real traffic, not from editing the database.<\/p>\n\n\n\n<figure class=\"wp-block-video\"><video controls preload=\"none\" poster=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-time-limits-poster.jpg\" src=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-time-limits.mp4\"><\/video><figcaption class=\"wp-element-caption\">The quota runs out and the tablet gets &#8220;Time&#8217;s up&#8221;. Then +30 minutes, pause, resume. 32 seconds, real time apart from the simulated clock.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Quota runs out and the tablet gets &#8220;Time&#8217;s up&#8221;. I press +30 min today and access comes back. I press Pause internet now and it&#8217;s blocked again 97 ms after the click. Resume and it works again. After each restore I open a different site in the tablet instead of reloading the old tab, and there&#8217;s a reason for that further down.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-tablet-window-closed.webp\" alt=\"Time&#x27;s up page on the tablet saying the internet is switched off and when it comes back\" loading=\"lazy\"\/><figcaption class=\"wp-element-caption\">The other way to get cut off: the 16:00 to 20:00 window closed.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">What it does in the kernel<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Enforcement is its own nft table, <code>inet patronus_time<\/code>, hooked at priority -11 so it runs ahead of the isolation table at -10. The docs say each change is one atomic <code>nft -f<\/code>, so other devices don&#8217;t see a blip when one device is toggled. A blocked tablet is three set elements: its IPv4 address in <code>blocked_v4<\/code>, its MAC in <code>blocked_mac<\/code> for IPv6, and the warning set for the two minutes after a warning.<\/p>\n\n\n\n<figure class=\"wp-block-image\"><img decoding=\"async\" src=\"https:\/\/blog.canutethegreat.com\/wp-content\/uploads\/2026\/11\/patronus-nft-time-table-1.webp\" alt=\"nft ruleset of the patronus_time table with the tablet address in the blocked set\" loading=\"lazy\"\/><figcaption class=\"wp-element-caption\"><code>nft list table inet patronus_time<\/code> while the tablet was blocked. The text is the real output. I added the colouring.<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">The router keeps answering ICMP and DNS for a blocked device and serves the page on :8081. I checked that ping and name lookups work, that the admin port times out, and that outbound TCP gets a reset. I did not test DHCP or SSH while blocked. After a simulated reboot (fresh namespaces plus <code>patronus apply<\/code>, no web UI yet) the tablet was already blocked and its usage was unchanged.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Timings from the lab: with a new TCP connection per probe, pause to first &#8220;Time&#8217;s up&#8221; response took 7 to 20 ms over 8 cycles, and resume to first real page 8 to 14 ms. Parent buttons act immediately. Window and quota changes are picked up by a ticker that runs every 5 seconds by default, so with the real default the page changed 4 to 5 seconds after a window edge.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Tests: 15 firewall unit tests and 2 captive-portal tests cover this code and they pass. The web crate has no time-limit unit tests of its own. There&#8217;s also a netlab scenario, <code>lane-s-time.sh<\/code>, which I did not run this time. No commit has touched the time-limit code since October 30.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What doesn&#8217;t work (yet)<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The one that annoyed me most is the stuck tab. A tab that was redirected to the time&#8217;s-up page keeps its connection to the router&#8217;s page server. After +30 min or Resume the old tab reloads, but it lands on the router&#8217;s own &#8220;You&#8217;re all set&#8221; page and stays there. In the runs where I kept reloading it, it took anywhere from 16 seconds to over two minutes to recover, and in one run it hadn&#8217;t recovered after 80 seconds. A new browser context or a different site works at once. Force-quitting the browser recovers faster than pressing reload. That&#8217;s why the clip opens a different site after each restore. I haven&#8217;t fixed it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">https gets nothing useful. Only port 80 is redirected, so on an https site the browser shows its own connection error and apps just say there&#8217;s no internet. The &#8220;Time&#8217;s up&#8221; page only shows up for plain http.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Identity is the device&#8217;s IPv4 address, plus its MAC for IPv6. With the tablet paused I gave the same client another address and the internet worked, because only the old address was in the blocked set. A device that isn&#8217;t enrolled isn&#8217;t limited at all. The docs admit a phone that rotates its MAC on every connection can&#8217;t be bound.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">IPv6 is cut but not counted. I got an IPv6 path working and the pause did stop it, but three simulated minutes of IPv6-only downloads left the usage at 4 minutes before and 4 after. The &#8220;Time&#8217;s up&#8221; redirect is IPv4 only too.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Accounting is a byte threshold per whole minute, so it isn&#8217;t a screen-time meter. One 47 KB response costs a full minute. Fifteen tiny connections in a minute cost nothing, thirty cost one. If you give a group a policy you get one quota per device, not a shared family pool, and bonus minutes are per device as well.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The enforcer lives in the web process. The ticker runs inside <code>patronus-web<\/code>. With it stopped and the clock moved 30 minutes past the end of the window, the tablet stayed online for the 10 seconds I watched. With it stopped and an already-blocked tablet, the tablet got connection refused instead of a page, since nothing was serving :8081. It catches up within a fraction of a second when the web process starts again.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">A transfer already running when I paused did not fail fast. A 10 second stream delivered about 16 KB before the pause and 20 KB shortly after, then stalled until the client&#8217;s own 14 second timeout.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Minor things: in the policy form the seven day checkboxes stack in one tall column, the &#8220;who it applies to&#8221; form doesn&#8217;t preselect the current policy, and the usage table refreshes on a 15 second timer, so the admin page lags the tablet by a few seconds.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Things I haven&#8217;t tried at all: a real DoH client or VPN app, the stricter mode that also cuts DNS, a per-device policy overriding a group one, captive-portal probes from a real Android or iPhone, DST or NTP steps, and anything over more than a day of real clock time. DNS stays open while blocked by default, and I didn&#8217;t look for anything that stops someone tunnelling through it.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Where it stands<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">It does the basic job in the lab: a device with a policy gets cut when its quota or window runs out, a parent can add time, pause or resume, and the block survives a reboot. It&#8217;s less finished than the changelog suggests. I&#8217;d fix the stuck tab first, since parents will think the button failed. I have no fixes for any of the items above yet.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Next: a few days on a real clock with a real phone.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Patronus lives at <a href=\"https:\/\/patronus.errant.solutions\/\">patronus.errant.solutions<\/a>.<\/p>\n\n\n","protected":false},"excerpt":{"rendered":"<p>Full disclosure: I make Patronus, a router and firewall OS built on Gentoo. It&#8217;s young. Version 0.2.0 came out on October 30. Most of what I write about it comes out of CI logs, and a green netlab run tells you very little about what a feature is like to use. So on November 8 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":660,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[22,26],"tags":[374,104,375,387,386],"class_list":["post-652","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","category-software-engineering","tag-firewall","tag-network-segmentation","tag-nftables","tag-parental-controls","tag-patronus"],"_links":{"self":[{"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/posts\/652","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/comments?post=652"}],"version-history":[{"count":3,"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/posts\/652\/revisions"}],"predecessor-version":[{"id":936,"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/posts\/652\/revisions\/936"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/media\/660"}],"wp:attachment":[{"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/media?parent=652"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/categories?post=652"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.canutethegreat.com\/index.php\/wp-json\/wp\/v2\/tags?post=652"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}