Go to file
Krzysztof kuhy Rudnicki ef892eb162 phone_focus_mode: block hotspot/tethering to close the second-phone bypass
The focus system only ever filtered this phone's own traffic: /system/etc/hosts
via the system resolver, dns_enforcer and the curfew net layer via OUTPUT. A
tethered second phone's packets are FORWARDed + NAT'd through us on a path none
of that covers, so a second phone on the hotspot browses freely on our mobile
data and defeats focus mode.

Add tether_enforcer.sh: an always-on daemon that acts while focus mode is ON
(at home) or a force-test file is present, converging three levers each tick:
  1. disable Android tether offload (settings global tether_offload_disabled=1,
     snapshot/restore) so forwarded traffic goes through netfilter;
  2. blanket REJECT of the FORWARD chain (iptables + ip6tables, FOCUS_TETHER_BLOCK
     pinned at position 1), rebuilt only when tampered via a chain_intact gate so
     it does not fork an `iptables -L` every second (that overheated the phone
     during curfew-net tuning). Covers WiFi, USB and BT tethering;
  3. best-effort `cmd wifi stop-softap` (Android 11+) so the hotspot visibly
     flips off.
Reverts offload + tears down FORWARD on transition away from home / on SIGTERM.

Wiring: config.sh flags, focus_ctl.sh (tether-status/start/stop/log/test-on/off),
magisk_service.sh boot autostart, deploy.sh push/cp/restart. README section and
a working subprocess regression test (lib/tests/test_tether_enforcer.sh, 17/17).

Verified on-device (BL9000, Android 13): our REJECT jump sits ABOVE Android's
tetherctrl_FORWARD chain, tether_offload_disabled=1 took effect, and
`cmd wifi stop-softap` reports "Soft AP stopped successfully".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q6i3cdhKBoUrKxy4rmx6hH
2026-07-13 10:48:59 +02:00
.github Harden phone_focus_mode CPU use; whitelist wake_alarm_sync 2026-07-11 00:16:11 +02:00
.hippo style: prettier format .hippo memory files 2026-05-28 07:05:24 +02:00
.vscode chore: archive 41 unmaintained directories to testsAndMisc-archive 2026-05-14 20:21:05 +02:00
bucket_catch style: prettier formatting on bucket_catch lockfile and package.json 2026-06-27 12:22:16 +02:00
docs phone_focus_mode: block hotspot/tethering to close the second-phone bypass 2026-07-13 10:48:59 +02:00
linux_configuration Extract dufs cloud (web + app + scripts) to github.com/kuhyx/dufs-cloud 2026-07-12 18:38:37 +02:00
meta linux_configuration: self-hosted dufs cloud storage + KeePass WebDAV auto-sync 2026-07-12 03:40:54 +02:00
phone_focus_mode phone_focus_mode: block hotspot/tethering to close the second-phone bypass 2026-07-13 10:48:59 +02:00
python_pkg Make code_tutor OSError fingerprint test Python-version-robust 2026-07-11 00:22:57 +02:00
third_party/agent-skills style(prettier): apply markdown/json formatting updates 2026-05-07 22:08:00 +02:00
.copilotignore chore: archive 41 unmaintained directories to testsAndMisc-archive 2026-05-14 20:21:05 +02:00
.fvmrc chore: consolidate root configs into meta/, drop unused C dir + split/pdfCentered/geo_data 2026-05-14 20:40:12 +02:00
.gitignore linux_configuration: self-hosted dufs cloud storage + KeePass WebDAV auto-sync 2026-07-12 03:40:54 +02:00
.pre-commit-config.yaml linux_configuration: self-hosted dufs cloud storage + KeePass WebDAV auto-sync 2026-07-12 03:40:54 +02:00
.prettierignore cloud_gallery: React media-gallery SPA served by dufs (Phase 3) 2026-07-12 06:05:52 +02:00
CLAUDE.md Extract dufs cloud (web + app + scripts) to github.com/kuhyx/dufs-cloud 2026-07-12 18:38:37 +02:00
lint_python.sh chore: consolidate root configs into meta/, drop unused C dir + split/pdfCentered/geo_data 2026-05-14 20:40:12 +02:00
pyproject.toml chore: consolidate root configs into meta/, drop unused C dir + split/pdfCentered/geo_data 2026-05-14 20:40:12 +02:00
README.md chore: consolidate root configs into meta/, drop unused C dir + split/pdfCentered/geo_data 2026-05-14 20:40:12 +02:00
requirements.txt chore: consolidate root configs into meta/, drop unused C dir + split/pdfCentered/geo_data 2026-05-14 20:40:12 +02:00
run.sh chore: consolidate root configs into meta/, drop unused C dir + split/pdfCentered/geo_data 2026-05-14 20:40:12 +02:00

testsAndMisc

A collection of personal projects, scripts, and experiments — from a GPS-based phone focus tool to Linux/Arch automation, with CI, linting, and pre-commit hooks across the board.

Highlights

Phone Focus Mode

Location-based app restriction for rooted Android. Automatically disables non-whitelisted apps within 500 m of home using ADB + Magisk. Features Haversine distance calculation, hysteresis to prevent toggling, fail-safe unlock, and state persistence. Bash, Android ADB.

Linux Configuration

Automated Arch Linux setup: fresh-install scripts, i3 window manager config, LaTeX environment, and system tests. Includes documentation and test result logging.

Scripts

Utility scripts for development workflows — build file validation, secret detection, and custom makepkg helpers.

Repository Layout

Path Description
python_pkg/ Python packages (each maintained subpackage lives here)
linux_configuration/ Arch Linux setup, i3 config, system maintenance scripts
phone_focus_mode/ GPS-based Android focus enforcer
scripts/ Workspace-level helper scripts and pre-commit hooks
docs/ Reference docs and historical reports
third_party/ Vendored upstream skills/agents
meta/ Repo-wide tooling: pyproject.toml, requirements.txt, .pre-commit-config.yaml, run.sh, lint_python.sh, .fvmrc. Symlinked into the repo root so tools that auto-discover from root keep working.

Archived / unmaintained projects live in the sibling repository testsAndMisc-archive.

Tooling

  • Python linting: Ruff with all rules enabled (see meta/pyproject.toml)
  • Dependencies: pip install -r meta/requirements.txt (combined runtime + dev)
  • CI: GitHub Actions — lint, build, and test on push
  • Testing: pytest (Python), custom shell-based test harness for scripts