Skip to main content

Overview

Device Pairing & Discovery enables ArgentOS to operate across multiple devices on the same network. The system uses Bonjour (mDNS/DNS-SD) for automatic gateway discovery and a structured pairing workflow for device registration with role-based access tokens. This system answers two questions:
  1. Discovery: Where is the ArgentOS gateway running on this network?
  2. Pairing: Is this device authorized to connect?

Bonjour Service Discovery

Service Type

ArgentOS gateways advertise as _argent-gw._tcp via mDNS/DNS-SD. This allows any device on the local network to discover running gateway instances without knowing their IP addresses.

Platform Support

TXT Record Fields

Each beacon advertises metadata via DNS TXT records:

Discovery Domains

Discovery searches multiple domains:
  1. local. — Standard mDNS local network discovery
  2. Wide-area domain — Optional Tailnet DNS for cross-network discovery

Tailnet Fallback

When standard Bonjour discovery fails for wide-area domains, the system falls back to a Tailnet-based DNS approach:
1

Query Tailscale

Query tailscale status --json for known peer IPs
2

Probe Peers

Probe each Tailnet IP for PTR records matching _argent-gw._tcp
3

Resolve Records

Resolve SRV and TXT records from the responding nameserver
4

Concurrent Probing

Concurrent probing (6 workers) with timeout budgets
This enables gateway discovery across Tailscale networks where mDNS may not propagate.

Discovery API

Device Pairing

Pairing State

Device pairing state is persisted to ~/.argentos/devices/:
Both files are written atomically (write to temp, rename) with 0o600 permissions for security.

Pairing Request

A device initiates pairing by sending a request with its identity:
Pending requests expire after 5 minutes if not approved.

Approval

The operator approves pairing on the primary device. On approval:
  1. The pending request is removed
  2. A paired device record is created
  3. A role-scoped auth token is generated
  4. If the device was previously paired, roles and scopes are merged

Rejection

Paired Device

Auth Tokens

Each paired device receives role-scoped auth tokens for API access.

Token Structure

Token Operations

Scope Enforcement

Token verification checks that requested scopes are a subset of the token’s allowed scopes:

Verification Failure Reasons

Concurrency Safety

All pairing operations use a serialized lock to prevent race conditions:
This ensures atomic state transitions even when multiple pairing requests arrive simultaneously.

Re-Pairing

When an already-paired device sends a new pairing request, the system detects this and sets isRepair: true. On approval, the existing device record is updated (roles and scopes are merged) rather than replaced.

Configuration

Device pairing state is stored under the ArgentOS state directory:
No configuration is needed to enable device pairing — it is available by default when the gateway is running.