mirror of
https://github.com/kuhyx/steam-backlog-enforcer.git
synced 2026-11-21 18:12:19 +01:00
Some checks are pending
dependency freshness / dependencies on newest stable (push) Waiting to run
md-naming / markdown naming convention (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (mypy, mypy, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (pylint, pylint, ) (push) Waiting to run
pre-commit / pre-commit (${{ matrix.group }}) (rest, , mypy,pylint) (push) Waiting to run
Tests / test (push) Waiting to run
Tests / web-coverage (push) Waiting to run
repo-contract / repo contract (push) Waiting to run
kuhy 2026-11-11: game-design research needs Librarian (app 4197610) actually played during the 6-day total block. New root command total-block-research --until T opens ONE window per lock: <= 48 h, never past the lock end, a rerun never extends it. The command only validates and records (/var/lib/steam-backlog- enforcer, root 0700; lock id + deadline + two latches). The daemon opens and closes everything: Steam hosts names, the store block, the total-block chain (IP cache kept) and the steam package, reinstalled with only guard-lib's package-block hook masked for that one pacman call (--hookdir, proved in a guest). Lock file, hook and end date are never touched. Browser-game sites stay null-routed. Only Librarian may run: loop-local allowed set, strict mode (no whitelist exceptions, no zero-achievement games), launchers and counted games killed; state.json is never read or written. Expiry latches the record, then the ordinary tick re-applies hosts (now reconciled each tick), chain, uninstall and purge; the normal store block is restored once, unconditionally. Failure modes: missing/corrupt/unparseable record = no window and a corrupt one also refuses a new window (fail closed); a clock set back cannot reopen a latched window. Checked: 3290 tests at 100% coverage; whole-tree pylint 10/10 run in three parts (the hook exceeds the 60 s cap, so SKIP=pylint here); vmbox guest with real guardctl package-block and the real unit, window opened, Librarian-only enforced, clock moved past the deadline and the full block re-applied. Not verified on the host. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWzuCEg1m87jpKyRrw
96 lines
3.3 KiB
Python
96 lines
3.3 KiB
Python
"""The domain lists a total gaming block makes unreachable.
|
|
|
|
A data table, versioned separately from the hosts/iptables mechanism that
|
|
consumes it in :mod:`steam_backlog_enforcer._total_block_net` -- adding a
|
|
storefront here should not mean touching blocking code.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from typing import Final
|
|
|
|
from steam_backlog_enforcer.config import BLOCKED_DOMAINS
|
|
|
|
TOTAL_BLOCK_DOMAINS = [
|
|
*BLOCKED_DOMAINS,
|
|
"steamcommunity.com",
|
|
"api.steampowered.com",
|
|
"login.steampowered.com",
|
|
"help.steampowered.com",
|
|
"steamcontent.com",
|
|
"steamstatic.com",
|
|
"steamusercontent.com",
|
|
"cdn.steamstatic.com",
|
|
]
|
|
|
|
# Browser/flash game sites. itch.io is deliberately absent: see
|
|
# TOTAL_BLOCK_EXEMPT_DOMAINS below.
|
|
GAME_WEBSITE_DOMAINS = [
|
|
"newgrounds.com",
|
|
"armorgames.com",
|
|
"kongregate.com",
|
|
"crazygames.com",
|
|
"poki.com",
|
|
"miniclip.com",
|
|
"addictinggames.com",
|
|
"y8.com",
|
|
"coolmathgames.com",
|
|
]
|
|
|
|
# EXCEPTION (kuhy, 2026-11-11: "itch io should be unblocked but only it"):
|
|
# a permanent, narrow hole so butler can publish his game and he can manage the
|
|
# itch page, while every other game site and Steam stay blocked. Nothing here is
|
|
# ever null-routed in /etc/hosts and its IPs are never dropped in iptables.
|
|
# Hosts: itch.io + www.itch.io (the page), api.itch.io and static.itch.io (both
|
|
# strings in the butler binary), kuhyx.itch.io (his account's page). butler
|
|
# uploads go to Google Cloud Storage via a URL the API returns (resumable
|
|
# upload), which is not blocked anywhere, so it needs no entry.
|
|
# TRADEOFF: itch is on shared Cloudflare IPs, and the iptables layer works per
|
|
# IP. When a still-blocked site sits on the same IP, the exception wins for
|
|
# that IP; /etc/hosts stays the primary block for the other site.
|
|
TOTAL_BLOCK_EXEMPT_DOMAINS: Final = (
|
|
"itch.io",
|
|
"www.itch.io",
|
|
"api.itch.io",
|
|
"static.itch.io",
|
|
"kuhyx.itch.io",
|
|
)
|
|
|
|
|
|
def _expand_with_www(domains: list[str]) -> list[str]:
|
|
"""Add a ``www.`` variant for each bare second-level domain.
|
|
|
|
Most of these sites 301-redirect their apex domain to ``www.<domain>``
|
|
(confirmed live for newgrounds.com) - blocking only the apex leaves the
|
|
www subdomain reachable through both the hosts-file entry and the
|
|
iptables IP block. Domains that already carry a subdomain (e.g.
|
|
store.steampowered.com) are left as-is.
|
|
"""
|
|
expanded: list[str] = []
|
|
for domain in domains:
|
|
expanded.append(domain)
|
|
if domain.count(".") == 1:
|
|
expanded.append(f"www.{domain}")
|
|
return expanded
|
|
|
|
|
|
_ALL_TOTAL_BLOCK_DOMAINS = [
|
|
domain
|
|
for domain in _expand_with_www([*TOTAL_BLOCK_DOMAINS, *GAME_WEBSITE_DOMAINS])
|
|
if domain not in TOTAL_BLOCK_EXEMPT_DOMAINS
|
|
]
|
|
|
|
# What /etc/hosts keeps null-routed while a research window has Steam open
|
|
# (``total-block-research``): the browser-game sites only. Steam is the one
|
|
# thing the window lends out, and Librarian is the one game it may be used for.
|
|
RESEARCH_BLOCKED_DOMAINS = [
|
|
domain
|
|
for domain in _expand_with_www(GAME_WEBSITE_DOMAINS)
|
|
if domain not in TOTAL_BLOCK_EXEMPT_DOMAINS
|
|
]
|
|
|
|
# The null-route redirect target used to make a blocked domain resolve
|
|
# nowhere - built from parts rather than the literal so linters don't
|
|
# mistake it for a socket bind-all-interfaces address (it never is one).
|
|
NULL_ROUTE_IP = ".".join(["0"] * 4)
|