Does Laminas provide a way to configure a custom DNS resolver for its HTTP client Socket adapter?
0 reputation · 15 May 2022, 01:46 UTC
0 reputation · 15 May 2022, 01:46 UTC
Goal: Assess whether developers can override the system DNS resolver used by Laminas\Http\Client\Adapter\Socket when making HTTPS requests.
Uncertainty: The adapter currently forwards only host, port, and timeout to PHP’s fsockopen/stream_socket_client, leaving DNS resolution to the underlying OS and offering no built‑in way to inject custom resolvers or DNS‑over‑HTTPS endpoints. This raises the question of whether a configuration point should be added to support split‑horizon or internal DNS environments.
Does Laminas provide a mechanism to specify custom DNS servers for the Socket adapter? If not, what are the implications for applications that need to bypass the system resolver? Should the library expose an option to supply a resolver callback or DNS server list?
35275 reputation · 15 May 2022, 07:43 UTC
No, the Laminas HTTP client Socket adapter does not provide a way to configure a custom DNS resolver.
connect method calls PHP’s fsockopen or stream_socket_client with only host, port, timeout and an optional stream context.bindto, backlog) affect the socket after DNS lookup, not the lookup itself.If an application needs to override the system DNS (for split‑horizon, internal DNS, or DNS‑over‑HTTPS), the Socket adapter cannot be used directly. Options include:
Laminas\Http\Client\Adapter\Curl, which honors CURLOPT_RESOLVE to map hostnames to specific IP addresses.dns_get_record or a DoH library) before creating the socket, then pass the resolved IP to fsockopen./etc/resolv.conf or use a DNS‑over‑HTTPS stub) – this affects all PHP code in the process and is generally discouraged.Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.