Skip to content

[Feature]: Add connection-level IPv4/IPv6 adapters (zero global state mutation) #18

@AHReccese

Description

@AHReccese

Describe the feature you want to add

All previous approaches (Lock, Thread-Local, ContextVar) modify the global socket.getaddrinfo function, either temporarily or permanently. This is inherently fragile: third-party libraries, monkey-patching tools, or unexpected code paths can observe the modified function.

We need an approach that enforces address family restrictions without touching any global state, by controlling DNS resolution at the urllib3 connection layer itself.

Describe your proposed solution

Introduce IPv4ConnectionAdapter and IPv6ConnectionAdapter that override urllib3's connection pool machinery.

Key properties:

  • Zero global state mutation: socket.getaddrinfo is never modified
  • Fully concurrent: no locks, no dispatchers, no shared mutable state
  • Architecturally cleanest: relies on documented urllib3 extension points

Describe alternatives you've considered, if relevant

No response

Additional context

No response

Metadata

Metadata

Assignees

Labels

No fields configured for Feature.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions