Skip to content

Expose k6 DNS Resolver for Extensions #5161

@szkiba

Description

@szkiba

This issue proposes exposing k6's internal DNS resolver to extensions, allowing them to benefit from the same DNS configurations as the core k6 modules.

Background

k6 provides a powerful and configurable DNS resolver that supports features like hosts overrides, custom DNS servers, and respecting DNS TTLs. This ensures consistent and controlled name resolution across all test scenarios. However, extensions that perform their own DNS lookups do not have access to this core resolver. This leads to inconsistent behavior, potential security issues (e.g., DNS hijacking), and a poor user experience as extension behavior may not match the k6 script's options.

Proposed Solution

Expose the core k6 DNS resolver as a publicly available Go API that extensions can use. This would allow extensions to perform DNS lookups that respect the user's k6 options, including:

  • hosts option: Honor any host overrides specified in the k6 script's options.hosts configuration.
  • Custom DNS servers: Use the DNS server configured in options.dns.
  • DNS caching: Benefit from k6's built-in DNS caching logic, which respects record TTLs.

By providing a unified DNS resolver API, we can ensure that all k6 extensions, regardless of their function, perform name resolution consistently and securely according to the user's test configuration. This will simplify extension development and improve the reliability of k6 tests.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions