Publish memorable mDNS records (kolibri.local + device-name) for stable, bookmarkable server URLs
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
On a DHCP-managed local network a Kolibri server's IP address is not stable — when its lease changes, any bookmarked http://<ip>:8080 URL breaks. mDNS/zeroconf should provide a stable, memorable, bookmarkable name that resolves to the current IP, but Kolibri only publishes <instance_id>.kolibri.local (a 32-hex-char morango instance id), never the bare kolibri.local or anything human-readable. So http://kolibri.local:8080 resolves to nothing and there is no durable URL for reaching a Kolibri server.
Publish two additional A records so users have durable, memorable URLs that keep working across IP changes:
kolibri.local— a bare, any-server name. Bookmark it to reach a Kolibri server on the LAN.<device-name>.kolibri.local— derived from the server's device name (e.g. "Tony's Laptop" →tonyslaptop.kolibri.local). Memorable, and far less likely to collide than the shared bare name, so on a typical LAN this is your server's durable URL.
Complexity: Medium Target branch: develop
Context
Kolibri's zeroconf broadcast lives in kolibri/core/discovery/utils/network/broadcast.py. Each instance publishes a per-device hostname built from its morango instance id:
LOCAL_DOMAIN = "kolibri.local" # :22
@property
def server(self): # :122-124
return ".".join([self.zeroconf_id, LOCAL_DOMAIN, ""])
So the advertised A record is <instance_id>.kolibri.local., never the bare kolibri.local or a name derived from the device name (device_info["device_name"], available on the instance). Nothing claims those names, so they don't resolve.
mDNS hostname behaviour that constrains the fix:
- A/AAAA records (
.localhostnames) are unique records (RFC 6762): a responder probes before claiming a name, and on conflict the late-comer must rename (kolibri-2.local, …). Kolibri's current per-instance-id hostname is always unique, so this never fires. - PTR records (the
_http._tcpservice-browse list) are shared — many devices advertising the Kolibri service is expected and already works; network discovery is unaffected. - Unlike the instance-id hostname, both new names are contendable, so the probe/rename mechanism above does fire when servers clash. A renamed loser still owns its per-instance hostname.
- We accept that the owner of a contended name is nondeterministic — it may change across restarts.
The three names form a hierarchy of durability vs. memorability:
| Name | Resolves to | Collision |
|---|---|---|
<instance_id>.kolibri.local |
this exact server, always | never (guaranteed unique) |
<device-name>.kolibri.local |
this server, unless renamed by conflict | only if two servers share a device name |
kolibri.local |
a server (nondeterministic owner) | always, when 2+ servers |
The Change
In addition to the per-instance <instance_id>.kolibri.local hostname it already publishes, each Kolibri server should also advertise:
- A bare
kolibri.localA record. - A
<device-name>.kolibri.localA record, where<device-name>is the server's device name (device_info["device_name"]) slugified to a valid DNS label.
Both point at the server's current IP and must track IP changes the same way the existing broadcast already does when interface addresses change. Do not force either name or suppress conflict handling — let mDNS elect the owner.
Slugifying the device name. The device name is free-form user text ("Tony's Laptop"); the record needs a valid, easy-to-type DNS label.
- Lowercase and drop characters outside
[a-z0-9-], so "Tony's Laptop" →tonyslaptop. - If the slug is empty (e.g. a name that is all whitespace or non-ASCII), publish no device-name record.
- Re-register the record when the device name changes after provisioning.
The names this server actually owns after conflict resolution (kolibri.local, tonyslaptop.kolibri.local, or their renamed forms) should be surfaced as URLs in the Device Info page's server-URL list (DeviceInfoPage.vue, fed by the kolibri:core:deviceinfo endpoint), alongside the existing IP-based URLs, so an admin can see and share the bookmarkable addresses.
How to Get There
- Start two Kolibri servers on the same LAN with different device names; confirm each owns its own
<device-name>.kolibri.local, one ownskolibri.local, and the other is renamed for the bare name. - Give two servers the same device name; confirm mDNS conflict resolution renames one (
tonyslaptop-2.local) and both remain reachable. - Resolve the names from another device (
ping kolibri.local,ping tonyslaptop.kolibri.local, or browse tohttp://…:<port>) and confirm they reach a running server. - Change the server's IP (e.g. renew its DHCP lease) and confirm both new records continue to resolve to the new IP.
- Rename the device in settings and confirm the old
<device-name>.kolibri.localstops resolving and the new one starts. - Set a device name that slugifies to empty; confirm no device-name record is published and the server is still reachable via
kolibri.local. - Open the Device Info page and confirm the owned
.localURLs appear in the server-URL list.
Out of Scope
- A portless
http://kolibri.localURL — that requires port-80 reachability and is tracked separately. - Changes to the service-browse/network-discovery behaviour (
_http._tcpPTR records) or the per-instance<instance_id>.kolibri.localhostname.
Acceptance Criteria
General
- [ ] Each Kolibri server advertises a bare
kolibri.localA record pointing at its current IP, in addition to the existing<instance_id>.kolibri.localhostname. - [ ] Each server also advertises a
<device-name>.kolibri.localA record, with the device name slugified to a valid DNS label; when the slug is empty, no device-name record is published. - [ ] Both new names resolve to a running Kolibri server from another device on the same LAN.
- [ ] When a name is contended (
kolibri.localwith 2+ servers, or<device-name>.kolibri.localwith a shared device name), exactly one server owns it via standard mDNS conflict resolution; the others are renamed (kolibri-2.local,tonyslaptop-2.local, …) and remain reachable via their per-instance hostname. - [ ] Both records update to follow the server's IP when interface addresses change, and the device-name record re-registers to follow a device rename.
- [ ] The names this server actually owns (
kolibri.localand<device-name>.kolibri.local, or their renamed forms) appear as URLs in the Device Info page's server-URL list.
Testing
- [ ] Tests cover that the broadcast publishes the bare
kolibri.localhostname and a slugified<device-name>.kolibri.localhostname. - [ ] Tests cover device-name slugification, including a name that slugifies to empty (no record published).
- [ ] Tests cover the multi-server conflict case for both names (one owner, others renamed and still reachable).
- [ ] Tests cover that the owned names are included in the Device Info URL list.
AI usage
Drafted with Claude Code. Claude investigated the zeroconf/mDNS broadcast code (broadcast.py) and the Device Info page to ground the description, confirmed the mDNS uniqueness behaviour and the port limitation against the code, and drafted the issue section by section from my notes and decisions. I directed the framing and split the portless-URL goal out as separate work.
Plan: Publish a bare kolibri.local A record and a <device-name>.kolibri.local A record (slugified) alongside the existing per-instance <instance_id>.kolibri.local mDNS hostname, so a Kolibri server has durable, memorable, bookmarkable URLs on a DHCP LAN, and surface the names this server actually owns in the Device Info page's URL list.
- [ ] Device-name slugification helper
- [ ] Claim
kolibri.localand<device-name>.kolibri.localon registration, with conflict-resolution renaming - [ ] Renew and unregister local names (IP/port refresh, device-rename re-claim, cleanup on stop)
- [ ] Expose owned local hostnames through
get_urls()(and thus the Device Info page) - [ ] Re-register the device-name alias when the device is renamed via the API
@rtibblesbot's comments are generated by an LLM, and should be evaluated accordingly
How was this generated?
- Implemented code following the pre-approved plan using test-driven development (red-green-refactor)
- Ran the project's full test suite and linter before committing
- For UI changes: captured live screenshots to verify rendering
- For backend changes: verified with example API/CLI output
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.
The bot has been waiting for a response for 2 hour(s). It will resume automatically when someone replies.