Skip to content

Let users pin the server address in Server connectivity - #657

Draft
zandercattapreta wants to merge 1 commit into
YACReader:developfrom
zandercattapreta:fix/server-pin-ip-address
Draft

zandercattapreta wants to merge 1 commit into
YACReader:developfrom
zandercattapreta:fix/server-pin-ip-address

Conversation

@zandercattapreta

Copy link
Copy Markdown

Refs #384

Problem

In Server connectivity, the address used for the QR code, the web UI link and "Copy link" is the first interface address, and the combo box selection was reset every time the dialog was shown or the theme changed. On networks where DHCP hands out a different IP, the address clients have to use keeps changing, and there was no way to set one.

Changes

  • The address combo box is now editable: an IPv4 address or a host name can be typed (the host name idea comes from the discussion in DHCP make me Crazy!!!! #384).
  • New pin button next to it. A pinned address is stored in YACReaderLibrary.ini (libraryConfig/SERVER_PINNED_ADDRESS) and is always used for the QR code, the web UI link and "Copy link". While pinned the field is locked; unpin to change it. If a pinned IPv4 is not assigned to any interface right now, a notice is shown.
  • The selection is kept instead of being reset every time.
  • This computer's name (<name>.local, <name>, <name>.<dns domain>) is offered at the end of the list, only if it resolves back to one of this machine's addresses (loopback does not count, so a 127.0.1.1 host entry in /etc/hosts is not enough). Lookups are asynchronous, so a name that is not announced cannot block the dialog.
  • pin.svg goes through the existing theme recoloring; the pin button has its own QSS in ServerConfigDialogTheme.
  • The listener is unchanged: it still listens on all interfaces. Pinning only changes the address that is advertised.

The pure logic lives in ip_config_helper (isValidServerHost, resolveServerAddress, localHostNameCandidates, resolvesToLocalAddress) with a new ip_config_helper_test.

Testing

  • Full build with CMake/Ninja and Qt 6 on macOS, ctest: 52/52 passing (including the new test).
  • Dialog tried by hand on macOS: pinning, persistence across closing/reopening the dialog, unpinning, invalid names disabling the pin.
  • Not tested yet: Windows and Linux. In particular, which of the .local / short name / domain candidates resolve there (mDNS needs avahi or systemd-resolved with mDNS enabled on Linux) still has to be checked on real machines. Light/dark themes were only checked on macOS.

Notes

  • Translation catalogs (.ts) are not updated, since feature PRs here usually leave that to the periodic "Update translations" commits. New strings: "Pin this address so it never changes", "Unpin this address", "This address is not assigned to this computer on the current network."
  • Scope is the desktop library app only.

🤖 Generated with Claude Code

The address shown in the server connectivity dialog (QR code, web UI link)
followed whatever interface address was first, and the selection was reset
every time the dialog was shown or the theme changed. On networks where DHCP
hands out a different IP the QR code kept changing.

- Make the address combo box editable: an IPv4 address or a host name can be
  typed.
- Add a pin button. A pinned address is stored in YACReaderLibrary.ini
  (libraryConfig/SERVER_PINNED_ADDRESS) and always used for the QR code, the
  web UI link and "Copy link", even if no interface currently has it, in
  which case a notice is shown. While pinned the field is locked.
- Keep the selected address instead of resetting it each time.
- Offer this computer's name (<name>.local, <name> and <name>.<dns domain>)
  next to the IPs, only when it resolves back to this machine. Lookups are
  asynchronous so a name that is not announced cannot block the dialog.
- Add pin.svg, themed through the existing recoloring, and a unit test for
  the address helpers.

Refs YACReader#384

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant