Repository navigation
feat(config): accept IPv6 listen addresses for API and proxy (ISSUE-18b) - #111
Conversation
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
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
left a comment
There was a problem hiding this comment.
Nice and small. IPv6 works, IPv4 untouched, no surprises. Merge it. Approving.
Summary
Implements ISSUE-18b (#107).
SettingsvalidatesTORPROXY_LISTEN_ADDRESS/TORPROXY_API_LISTEN_ADDRESSwithipaddress.ip_address()(IPv4 or IPv6) instead ofIPv4Addressonly. Invalid values still raise the existingValueErrorstyle; noteip_address()raises plainValueError, notAddressValueError.ProxyHTTPServerbinds anAF_INET6socket for IPv6 addresses,AF_INETotherwise. Defaults (0.0.0.0) and IPv4 behavior unchanged.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
tests/unit/test_ipv6.py(6 tests:::1/::accepted, default unchanged, invalid rejected, real::1bind) 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→ cleanNot run: container smoke with IPv6 networking (requires Docker daemon / IPv6 host network; CI covers the image build).
Closes #107