Skip to content

feat(config): accept IPv6 listen addresses for API and proxy (ISSUE-18b) - #111

Merged
hapheus merged 2 commits into
mainfrom
feat/issue-107-ipv6-listen
Nov 7, 2026
Merged

hapheus merged 2 commits into
mainfrom
feat/issue-107-ipv6-listen

Conversation

@hapheus

@hapheus hapheus commented Nov 7, 2026

Copy link
Copy Markdown
Owner

Summary

Implements ISSUE-18b (#107).

  • Settings validates TORPROXY_LISTEN_ADDRESS / TORPROXY_API_LISTEN_ADDRESS with ipaddress.ip_address() (IPv4 or IPv6) instead of IPv4Address only. Invalid values still raise the existing ValueError style; note ip_address() raises plain ValueError, not AddressValueError.
  • ProxyHTTPServer binds an AF_INET6 socket for IPv6 addresses, AF_INET otherwise. Defaults (0.0.0.0) and IPv4 behavior unchanged.
  • Docs (docs/configuration.md, docs/compatibility.md) updated from "IPv4 address" to "IP address (IPv4 or IPv6)".

Compatibility: additive — existing IPv4 values keep working, new IPv6 values become valid. No port/API change.

Verification

  • TDD: tests/unit/test_ipv6.py (6 tests: ::1/:: accepted, default unchanged, invalid rejected, real ::1 bind) failed before the fix, passes after.
  • uv run pytest tests/unit/ -q --cov=torproxy --cov-fail-under=85 → 323 passed, coverage 85.92%
  • uv run ruff check ., uv run ruff format --check ., uv run mypy, shellcheck docker/*.sh tests/integration/*.sh → clean

Not run: container smoke with IPv6 networking (requires Docker daemon / IPv6 host network; CI covers the image build).

Closes #107

ISSUE-18b (#107): TORPROXY_LISTEN_ADDRESS and
TORPROXY_API_LISTEN_ADDRESS were IPv4-only
(ipaddress.IPv4Address), so ::1/:: were rejected.

- Validate with ipaddress.ip_address() (IPv4 or IPv6);
  invalid values still fail with the existing error style.
  Note: ip_address() raises plain ValueError, not
  AddressValueError — catch ValueError.
- Bind an AF_INET6 socket in ProxyHTTPServer for IPv6
  addresses; IPv4 behavior and defaults (0.0.0.0) unchanged.
- Docs: configuration.md and compatibility.md now document
  IP (v4 or v6) instead of IPv4-only.

Closes #107

@MustermenschAlex MustermenschAlex left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks — a proper additive IPv6 implementation.

ipaddress.ip_address() validation in configuration.py and the AF_INET6 bind in ProxyHTTPServer are the minimal, correct changes; defaults (0.0.0.0) and IPv4 behavior are untouched, and docs in configuration.md/compatibility.md match the code. The real ::1 bind test (with a graceful skip) is a good hermetic compromise.

One thing I appreciated: the ValueError vs. AddressValueError catch was actually fixed rather than worked around. All checks green. Approving.

@kuenstlichedummheit-sys kuenstlichedummheit-sys left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IPv6 support without breaking IPv4 — the dream. One : check to pick the socket family, validation relaxed, defaults unchanged. I also like that the "invalid address" test caught the plain-ValueError subtlety; that's the kind of bug that otherwise ships silently.

Docs say loopback for production, which is the sane default. Approving.

@majorungustl majorungustl left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice and small. IPv6 works, IPv4 untouched, no surprises. Merge it. Approving.

@hapheus
hapheus merged commit c80b5c2 into main Nov 7, 2026
11 checks passed
@hapheus
hapheus deleted the feat/issue-107-ipv6-listen branch November 10, 2026 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ISSUE-18b] IPv6 listen addresses for API and HTTP proxy

4 participants