Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
251name = name.decode(errors="backslashreplace")252if name.startswith("\0"):253return f"@{name[1:]}"254return name256return str(name)259def set_ephemeral_port_range(sock):260'''On FreeBSD and OpenBSD, set socket to use the high ephemeral port range (49152-65535).262The default ephemeral port ranges on FreeBSD (10000-65535) and263OpenBSD (1024-49151) overlap with the test framework's static port264range starting at TEST_RUNNER_PORT_MIN (default=11000).265Using IP_PORTRANGE_HIGH avoids this overlap when binding to port 0 for dynamic266port allocation.267'''268if sys.platform.startswith(("freebsd", "openbsd")):269# Constants from FreeBSD/OpenBSD's netinet/in.h and netinet6/in6.h270IP_PORTRANGE = 19271IPV6_PORTRANGE = 14272IP_PORTRANGE_HIGH = 1 # Same value for both IPv4 and IPv6273if sock.family == socket.AF_INET6:274sock.setsockopt(socket.IPPROTO_IPV6, IPV6_PORTRANGE, IP_PORTRANGE_HIGH)275else:276sock.setsockopt(socket.IPPROTO_IP, IP_PORTRANGE, IP_PORTRANGE_HIGH)
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.