pappl icon indicating copy to clipboard operation
pappl copied to clipboard

dnssd.c: Enable service registration on loopback

Open zdohnal opened this issue 11 months ago • 0 comments

In case users would like to prevent sharing services from printer applications to local network, restrict it to localhost and let CUPS do the sharing.

This can be done by setting listen-hostname in PAPPL API - this prevents accessing the public addresses, but the service is still published on those public addresses. This can be prevented if the machine hostname is changed to localhost, but that's not desired on machines IIUC.

The PR does the following:

  • introduced new pappl system member reghost, which is used for saving listen-hostname,
  • new public accessors for that member, papplSystemSetRegHostName() and papplSystemGetRegHostName() - user can set the member to localhost or to the current hostname
  • dnssd functions will check this member, and if it is localhost, it will use loopback index
  • in case of Avahi it passes NULL as hostname to let Avahi decide what hostname to use (in case of hostname conflicts - and Avahi forbids using localhost if it is not FQDN)

The result is that if reghost is set to localhost, the service is published on .local address, but resolved to loopback because CUPS uses DNS-SD names in URIs.

zdohnal avatar Feb 28 '24 16:02 zdohnal