Skip to content

openwrt-presence-agent: add package - #30094

Open
theoabw wants to merge 1 commit into
openwrt:masterfrom
theoabw:add-openwrt-presence-agent
Open

openwrt-presence-agent: add package#30094
theoabw wants to merge 1 commit into
openwrt:masterfrom
theoabw:add-openwrt-presence-agent

Conversation

@theoabw

@theoabw theoabw commented Jul 25, 2026

Copy link
Copy Markdown

Package details

Maintainer: @theoabw

This adds openwrt-presence-agent, an authenticated, read-only local service that publishes normalized Wi-Fi and Ethernet client presence. The package follows the signed upstream v0.2.3 release.

Wi-Fi presence combines low-latency hostapd events with authoritative corrective snapshots. Snapshot clients count as present only when hostapd reports them as both associated and authorized. Reconciliation also removes clients and providers that disappear between snapshots.

Ethernet presence treats DHCP leases only as candidate MAC/IP pairs. Fresh Linux neighbor events or bounded active ARP replies confirm presence; stale leases, neighbor entries, and bridge forwarding entries do not count as online.

The package installs the service binary, procd init script, and UCI configuration. It depends on ubus and iputils-arping, using the packaged /usr/bin/arping executable. Configuration and generated credentials are preserved during upgrades.

Testing

  • Package version: 0.2.3
  • Source archive SHA-256: da79dce581a436d92bddcd94375b749f90f98fb16f3b98cc55678219a0c16b7d
  • Upstream unit, race, formatting, vet, shell, and package checks pass via scripts/check.sh
  • Upstream PR CI passed CodeQL and official OpenWrt 24.10.7/25.12.5 x86_64 SDK builds
  • The v0.2.3 release check and hardware-vendor package build pass; its full official SDK matrix is running
  • Live-tested on a GL.iNet Flint 3 with Home Assistant integration v0.2.1
  • Live Wi-Fi and wired providers report healthy, and the HA stream reconnects after a deliberate agent restart
  • Init script passes ShellCheck
  • OpenWrt code, commit, and Makefile formality checks pass

Formalities

This PR does not contain downstream source patches, so patch-specific formalities do not apply.

@theoabw
theoabw force-pushed the add-openwrt-presence-agent branch 2 times, most recently from 981ec55 to 11a1825 Compare July 25, 2026 16:58

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 1 new commit. Commit message matches the diff; comments inline.

Verified along the way (no action needed): upstream tag v0.1.1 exists, LICENSE and NOTICE are both present in the tarball so PKG_LICENSE_FILES is correct, main.version is the right -X symbol, and every UCI option in the shipped config maps to a real flag in internal/config with a matching default.


Generated by Claude Code

Comment thread net/openwrt-presence-agent/Makefile Outdated
Comment thread net/openwrt-presence-agent/files/openwrt-presence-agent.init Outdated
Comment thread net/openwrt-presence-agent/test-version.sh Outdated
@theoabw
theoabw force-pushed the add-openwrt-presence-agent branch from 11a1825 to 0a3418e Compare July 26, 2026 22:17

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the force-push (11a18250a3418e). All three findings from the previous round are addressed: base64 is gone in favour of a BusyBox-safe tr/head generator in both postinst and the init script, and test-version.sh was dropped so the generic version check applies again.

Commit checks

  • 0a3418e "openwrt-presence-agent: add package" — the commit body still describes the service as publishing "normalized Wi-Fi client snapshots" only, but this revision adds the Ethernet/ARP path (new arping dependency, arping_path/dhcp_leases_file/lan_interface/wired_reconcile_interval options) and the package description was updated to "Wi-Fi and Ethernet". Worth updating the commit body to match, since it is the version bump's main user-visible change.

Two inline issues on the new Ethernet support, plus one nit.

Note: I could not verify the upstream v0.2.1 tag, the PKG_HASH, or that the four new --* flags exist in internal/configtheoabw/openwrt-presence-agent is outside the repository scope available to this session, so unlike last round those checks are unverified rather than confirmed.


Generated by Claude Code

Comment thread net/openwrt-presence-agent/Makefile Outdated
Comment thread net/openwrt-presence-agent/files/openwrt-presence-agent.config Outdated
Comment thread net/openwrt-presence-agent/files/openwrt-presence-agent.config

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed the new commit (0a3418e7344414). Both findings from the previous round are fixed correctly, and I could verify both against the tree this time:

  • +iputils-arping is a real package in this feed and installs the binary to /usr/bin/arping (net/iputils/Makefile:84-86), so the new arping_path default now points at a path something actually provides.
  • PKG_RELEASE correctly stays at 1 across the 0.2.10.2.3 bump.
  • Spot-checked the other two hardcoded paths in the shipped config while I was here: /bin/ubus matches what the ubus package installs (package/system/ubus/Makefile:62) and /var/run/hostapd/global matches the global control socket wpad opens (wpad.init:14).

Nothing blocking in the diff itself; two nits inline.

Commit checks

  • 7344414 "openwrt-presence-agent: address review feedback" — the subject names the process rather than the change, and the diff matches the body, but this commit only repairs things 0a3418e introduced in this same PR: a DEPENDS entry on a package that does not exist and a binary path that nothing installs. Merging as-is puts a commit adding a broken new package into the tree followed by a commit fixing it. CONTRIBUTING.md's PR advice points at git rebase -i + git push -f for exactly this case. Squashing back into a single openwrt-presence-agent: add package commit would also let you fix that commit's body, which still describes the service as publishing "normalized Wi-Fi client snapshots" only and never mentions the Ethernet path — the same gap I raised last round, still unaddressed because the fix landed in a second commit instead of an amend.

    Minor: the body's rationale "so package installation succeeds" does not match the actual failure mode. An unknown DEPENDS entry is only warned about and then dropped by the metadata scanner (scripts/package-metadata.pl:465), so installation did succeed before — arping was simply absent at runtime and the wired probe path degraded silently. Worth rewording if you re-roll the commit anyway.

CI on 7344414 is still pending with no completed checks, so there is nothing to read there yet.

Not verified this round: the v0.2.3 tag, PKG_HASH, and whether the UCI options still map 1:1 to flags in internal/config at that tag — theoabw/openwrt-presence-agent is outside the repository scope available to this session and the tarball fetch is blocked, so the version bump itself is taken on trust.


Generated by Claude Code

Comment thread net/openwrt-presence-agent/Makefile Outdated
Comment thread net/openwrt-presence-agent/Makefile Outdated
@theoabw
theoabw force-pushed the add-openwrt-presence-agent branch from 7344414 to 649e25b Compare July 31, 2026 23:21
@theoabw
theoabw force-pushed the add-openwrt-presence-agent branch from 649e25b to b2f7298 Compare July 31, 2026 23:22

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the rebase (7344414b2f7298). The series is now a single openwrt-presence-agent: add package commit, which resolves the main point from last round — there is no longer an add-then-fix pair going into the tree, and the commit body now describes the Ethernet path (Fresh neighbor events or ARP replies confirm presence) instead of the Wi-Fi-only wording. The message matches the diff, so no commit checks this round.

Both nits from last round are also addressed, and the content diff since 7344414 is exactly those two fixes:

  • PKG_MAINTAINER moved to Theo Wilenius <theo@tabw.dev>, which now matches the author and Signed-off-by on the single commit.
  • The package description dropped "only fresh ARP replies" in favour of "fresh neighbor events or ARP replies", agreeing with the PR body.

One inline issue, on the token_file UCI option versus the hardcoded bootstrap path in the init script. It predates this revision — I missed it in earlier rounds — but since the package has not merged yet it seems better to raise it now than as a follow-up.

Still not verified: the v0.2.3 tag, PKG_HASH, and whether the 22 UCI options map 1:1 to flags in internal/config at that tag. theoabw/openwrt-presence-agent is outside the repository scope available to this session, so the version bump is taken on trust as in the previous round.

CI on b2f7298: the three FormalityCheck runs are green; no build or test job has reported yet, so there is nothing to read there.


Generated by Claude Code

Comment on lines +58 to +67
start_service() {
umask 077
mkdir -p /etc/openwrt-presence-agent
if [ ! -s /etc/openwrt-presence-agent/token ]; then
tr -dc 'A-Za-z0-9' < /dev/urandom | head -c 48 > /etc/openwrt-presence-agent/token
fi
chmod 600 /etc/openwrt-presence-agent/token
config_load openwrt-presence-agent
config_foreach start_instance observer
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The token bootstrap hardcodes /etc/openwrt-presence-agent/token, but the path the agent actually reads is the UCI option token_file, passed through as --token-file (openwrt-presence-agent.init:31, default at openwrt-presence-agent.config:5).`` The two only agree as long as the user leaves token_file alone.

Change option token_file to anything else — a different filename, or persistent storage on a device where /etc is small — and start_service still creates and chmods the default file, then starts the agent with --token-file <other path>, which does not exist. Given readToken() refuses tokens shorter than 43 chars, the agent exits, procd burns its 5 respawn retries, and the operator is left with a populated token file at a path nothing reads. Since token_file is exposed as a knob and the whole point of the config file is that it is editable, that is a foot-gun rather than a theoretical case.

The end state to aim for: derive the path from the section before generating, rather than assuming the default. Note config_load currently runs after the bootstrap, so this needs a small reorder — either move config_load above the token block and read the path from the main section, or move the bootstrap into start_instance() so it runs per-section with that section's token_file. The latter is more consistent with config_foreach iterating over every observer section, so I have not put a suggestion block here.

postinst has the same hardcoded path, but there it is fine: at install time the shipped default is the only value that can be in effect.


Generated by Claude Code

Add an authenticated local service that publishes normalized Wi-Fi and Ethernet
client presence for trusted local consumers.

Combine low-latency hostapd and neighbor events with corrective snapshots and
bounded ARP probes.

DHCP leases provide candidate wired addresses. Fresh neighbor events or ARP
replies confirm presence.

Include procd and UCI integration, persistent on-device credentials, and
dependencies on ubus and iputils-arping.

Release: https://github.com/theoabw/openwrt-presence-agent/releases/tag/v0.2.3

Signed-off-by: Theo Wilenius <theo@tabw.dev>
@theoabw
theoabw force-pushed the add-openwrt-presence-agent branch from b2f7298 to 78a3f43 Compare August 1, 2026 18:39

@openwrt-ai openwrt-ai left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Re-reviewed after the amend (b2f729878a3f43). The series is still a single openwrt-presence-agent: add package commit and the message matches the diff, so no commit checks this round.

The only content change since b2f7298 is the token bootstrap moving out of start_service into start_instance, where the path now comes from the section's token_file — that is exactly the fix for last round's finding, and it also stops generating a token for sections with enabled 0. umask 077 stays in start_service, which still covers the generation because config_foreach runs in the same shell, and the mkdir/chmod failures now bail out before procd_open_instance instead of starting a broken instance.

One follow-on inline: the resolved path is not the one handed to the agent, because --token-file still goes through append_option.

Not verified, same as previous rounds: the v0.2.3 tag, PKG_HASH, and whether the 22 UCI options map 1:1 to flags in internal/configtheoabw/openwrt-presence-agent is outside the repository scope available to this session (get_tag there is refused), so the release is taken on trust.

CI on 78a3f43: the three FormalityCheck runs are green; no build or test job has reported, so there is nothing to read there.


Generated by Claude Code

procd_set_param command /usr/bin/openwrt-presence-agent
append_option "$section" listen_address --listen-address
append_option "$section" port --port
append_option "$section" token_file --token-file

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bootstrap now resolves token_file with a default (line 27), but this line passes the option through append_option, which does a plain config_get with no default and drops the flag when the value is empty.`` So the two halves can still disagree, just in the opposite direction from last round: delete or blank option token_file in a section (or add a second `observer` section without it) and the script generates a token at `/etc/openwrt-presence-agent/token` while the agent is started with no `--token-file` at all and falls back to its own compiled-in default.

Since the resolved path is already in $token_file, passing it directly removes the second lookup and guarantees the agent reads exactly the file that was just created and chmod'ed:

Suggested change
append_option "$section" token_file --token-file
procd_append_param command --token-file "$token_file"

(If the agent's built-in default is /etc/openwrt-presence-agent/token, the practical impact is nil for the single-section case — I can't check internal/config from here, see the review body. The multi-section case still shares one token file across observers either way.)


Generated by Claude Code

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new OpenWrt net/ package for openwrt-presence-agent, a Go-based local presence observation service intended to publish authenticated Wi‑Fi/Ethernet client presence information to trusted local consumers.

Changes:

  • Introduces a new net/openwrt-presence-agent package Makefile for fetching/building/installing the Go binary and config/init assets.
  • Adds a procd init script to run the daemon with UCI-configurable flags and safe token-file permissions.
  • Adds a default UCI config with sensible localhost binding and default paths for ubus, hostapd, and arping.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.

File Description
net/openwrt-presence-agent/Makefile New package definition: source, Go build wiring, install steps, conffiles, and postinst token generation.
net/openwrt-presence-agent/files/openwrt-presence-agent.init New procd init script that loads UCI and maps options to CLI flags.
net/openwrt-presence-agent/files/openwrt-presence-agent.config New default UCI configuration for the service.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@@ -0,0 +1,76 @@
# SPDX-License-Identifier: Apache-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants