Skip to content

Development

MateusBMP edited this page Nov 16, 2026 · 2 revisions

Development

Running from source

No installation or root needed. The daemon listens on an unprivileged port and does not touch the firewall:

# daemon on port 5300, with its own D-Bus name on the session bus
BLOCKADS_STATE_DIR=/tmp/state PYTHONPATH=src python3 -m blockads_linux.daemon \
    --dev --listen 127.0.0.1:5300 --state-dir /tmp/state --log-queries \
    --dbus session --dbus-allow-all

# download and compile the enabled lists through it
BLOCKADS_STATE_DIR=/tmp/state PYTHONPATH=src python3 -m blockads_linux.updater --resolver 127.0.0.1:5300

# CLI and GUI against the session bus
PYTHONPATH=src python3 -m blockads_linux.ctl --bus session status
PYTHONPATH=src python3 -m blockads_linux.gui --bus session      # --hidden, --page log

--list FILE loads a hosts or adblock file directly, without the updater. Query it with any DNS client on port 5300.

Repository layout

src/blockads_linux/
  common/    paths, settings schema, D-Bus API names, Android importer, diagnostics
  filters/   parser, custom rules, artifact, matcher, catalog (data/catalog.json)
  daemon/    server, pipeline, upstreams (plain, TCP, DoT, DoH, stamps, policy), cache,
             health, log store, statistics, D-Bus service, polkit, trusted networks
  updater/   fetch, compile, manifest
  ctl/       blockadsctl
  gui/       PyQt6 app, pages, tray, wizard, charts, i18n
helper/      blockads-fw (root helper, stdlib only), blockads-fw-emergency.sh
data/        systemd units, sysusers, tmpfiles, D-Bus and polkit policy, desktop files, icons
tools/       gen_catalog.py, go_oracle/ (parity check with the upstream Go compiler), i18n/, ci/
tests/       unit/, netns/, vm/, ci/, fixtures/

Tests

Suite Command Needs
Unit python -m pytest -q nothing (no root, no network); GUI tests run offscreen
Firewall and offline tests/netns/*.sh (interception, offline_resolver, storage_enospc, fw_helper, self_healing, bridge, gui_offline) rootless user + network namespaces (unshare -Urn); never touches the host firewall
Platform / system tests/vm/run_platform.sh IMAGE..., tests/vm/run_system.sh IMAGE... qemu/KVM; disposable VMs from the distributions' cloud images (tests/vm/vm.sh lists them)

The system suite installs the real units and injects faults: kill -9, SIGSTOP (watchdog), flushed rules, firewalld/ufw/Docker reloads, reboot, uninstall while running, port taken, resolved DoT, captive portal, clock in 2001, the bridge redirect with Docker/podman/libvirt, and more.

Parity with upstream: tools/go_oracle/run.sh URL... compiles lists with the upstream Go compiler at a pinned commit and compares the domain sets. Regenerate the catalog only with tools/gen_catalog.py.

CI

.github/workflows/ci.yml:

  • Every push and pull request: unit and netns in the official containers of Debian 12/13, Ubuntu 24.04/26.04, Fedora 44 and Arch, each with its own packages (tests/ci/container.sh). The legacy iptables modules are loaded on the runner, so a SKIP fails the job.
  • Push to main, weekly and manual dispatch: system natively on the Ubuntu 24.04/26.04 runners (tests/ci/system.sh), and vm in qemu/KVM for Debian 12/13, Fedora 44 and Arch.
  • tools/ci/report.py turns the logs into error annotations and a summary table per job, starting with the distribution's package versions. Logs and VM consoles are uploaded as artifacts for 14 days.

Translations

The GUI uses Qt Linguist. English is the source; Brazilian Portuguese is complete.

  • Translate in tools/i18n/<lang>.py (a source → translation table), then run python3 tools/i18n/update.py. It extracts the strings (pylupdate6), fills the .ts and compiles the .qm (lrelease). --check exits 1 when a string has no translation.
  • The .ts files are committed; the .qm files are build products. python3 tools/i18n/update.py --compile only compiles them (used by CI and packaging).
  • A unit test fails when the shipped .ts is stale.

Clone this wiki locally