Autoproxy allows |CL| to operate seamlessly behind a proxy
because, :ref:`swupd-guide` and other |CL| tools are implemented on
top of libcurl. Tools that do not use libcurl, like git, must
be configured independently. 

If you encounter problems with autoproxy functioning, use
:command:`pacdiscovery` and :command:`FindProxyForURL` to
help troubleshoot assuming a familiarity with PAC files and WPAD. 

.. note::

   Learn more about WPAD, PAC files, and PAC functions at `findproxyforurl`_.

.. _findproxyforurl: http://findproxyforurl.com/

Running :command:`pacdiscovery` with no arguments will immediately indicate

1. if there is a problem resolving the :command:`WPAD` host name resolution: 

   .. code:: console

      $ pacdiscovery
      failed getaddrinfo: No address associated with hostname
      Unable to find wpad host

2. or if the :command:`pacrunner` service is disabled (masked).

   .. code:: console

      $ pacdiscovery
      PAC url: http://autoproxy.your.domain.com/wpad.dat
      Failed to create proxy config: Unit pacrunner.service is masked.

Unmask the :command:`pacrunner` service by running:

.. code:: console

   $ systemctl unmask pacrunner.service

:command:`FindProxyForURL` with :command:`busctl` can also indicate if the
:command:`pacrunner.service` is masked.

.. code:: console

   $ busctl call org.pacrunner /org/pacrunner/client org.pacrunner.Client FindProxyForURL ss "http://www.google.com" "google.com"
   Unit pacrunner.service is masked.
   dig wpad, dig wpad.<domain>

:command:`FindProxyForURL` returns the URL and port of the proxy server when
an external URL and host are provided as arguments.

.. code:: console

   $ busctl call org.pacrunner /org/pacrunner/client org.pacrunner.Client FindProxyForURL ss "http://www.google.com" "google.com"
   s "PROXY proxy.your.domain.com:<port>"

If a proxy server is not avialable, or if :command:`pacrunner` is running
without a PAC file, :command:`FindProxyForURL` will return "DIRECT". 

.. code:: console

   $ busctl call org.pacrunner /org/pacrunner/client org.pacrunner.Client FindProxyForURL ss "http://www.google.com" "google.com"
   s "DIRECT"

Once :command:`pacdiscovery` is able to look up :command:`WPAD`, restart the
:command:`pacrunner` service:

.. code:: console

   $ systemctl stop pacrunner
   $ systemctl restart pacdiscovery

.. note::

   A "domain" or "search" entry in :file:`/etc/resolv.conf` is required for short
   name lookups to resolve. The :file:`resolv.conf` man page has additional
   details.