If libproxy returns a proxy URI while the next socket connects directly, check the handoff. libproxy discovers policy; it does not intercept every socket the application opens.

  1. Query for the resource. In the documented libproxy 0.5 C API, create a proxy factory and ask for the actual destination URL.
  2. Interpret the ordered candidates. HTTP, SOCKS and direct results need different handling. Keep their preference order and the intended failure policy.
  3. Configure the consumer. Give the chosen proxy type, endpoint and authentication arrangement to a transport that supports them. A raw TCP socket does not acquire CONNECT or SOCKS negotiation from a returned URI.

Do not save one answer as the route for every destination or make direct routing permanent because the first proxy failed once.

If the HTTP client already integrates system proxy or PAC discovery, choose one selection owner. Two independent selectors plus another wrapper can produce a route neither policy intended.

In native code, follow the installed API's factory and result-memory lifecycle. Reusing a factory can retain useful discovery state, but it still needs a query for each destination. Log selection separately from connection outcome: a returned URI does not establish successful authentication, resolution or onward access.

Artihkkalat mat laktásit