Skip to content

Support injecting a custom DNS resolver to allow filtered IPs during MQTT connection #77

Description

Problem Statement

Today, when connecting to an MQTT broker using a hostname, DNS resolution happens implicitly and the returned IPs are used directly for connection. While applications can perform pre-validation of DNS results (e.g., resolving the hostname first and filtering out restricted IP ranges), there is currently no way to pass a filtered/approved list of IP addresses into the MQTT connection itself.
This creates a gap where:

  • A hostname may be validated ahead of time

  • But a subsequent DNS resolution at connection time may still return a restricted IP

This is particularly relevant for scenarios where clients must connect to arbitrary or user-provided endpoints, such as connectors.

Proposed Enhancement

Allow callers to inject a custom DNS resolver into the MQTT client so that:

  • DNS resolution occurs through caller-controlled logic

  • Restricted IPs can be filtered out during resolution

  • Only the approved IPs are returned and used for the connection attempt

Injecting the resolver would make DNS validation:

  • Seamless (part of normal resolution flow)

  • Safer (no mismatch between validation-time resolution and connect-time resolution)

  • More efficient (avoids redundant DNS lookups)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions