Author: Pietro Cerutti <[email protected]>
State: Withdrawn
Type: Project
Vote: Pending
Created: 17-Sep-2026
Post-History:
Tcl-Version: 9.1
Keywords: tcltest
Tcl-Branch: gahr-no-hardcoded-ip-addresses
Vote-Summary:
Votes-For:
Votes-Against:
Votes-Present:
Abstract
This TIP proposes two new functions in the tcltest namespace, for
auto-discovery of the IPv4 and IPv6 address of the local interface.
Rationale
Tests in core currently hardcode 127.0.0.1 and ::1 for the local IPv4 and
IPv6 address. This is problematic on systems where the local interface uses
different addresses, e.g., on a FreeBSD jail with no loopback interface. It
also doesn't allow any parameterization by users.
Specification
The two functions localIPv4Address and localIPv6Address are added to the
tcltest namespace. The functions perform auto-discovery and returns the first
match in the following heuristics, caching the results for subsequent calls.
- the contents of the
TCLTEST_IPV4orTCLTEST_IPV6environment variable - the addresses on a server socket opened with
-myaddr localhost - the addresses on a server socket opened without a
-myaddrparameter - 127.0.0.1 and ::1, respectively
IPv4 and IPv6 are discovered independently, i.e., one can set TCLTEST_IPV6
and rely on the above heuristics for IPv4.
Implementation
See the gahr-no-hardcoded-ip-addresses branch.
Copyright
This document has been placed in the public domain.
