mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-06-30 02:31:05 +02:00
Merge bitcoin/bitcoin#27375: net: support unix domain sockets for -proxy and -onion
567cec9a05
doc: add release notes and help text for unix sockets (Matthew Zipkin)bfe5192891
test: cover UNIX sockets in feature_proxy.py (Matthew Zipkin)c65c0d0163
init: allow UNIX socket path for -proxy and -onion (Matthew Zipkin)c3bd43142e
gui: accomodate unix socket Proxy in updateDefaultProxyNets() (Matthew Zipkin)a88bf9dedd
i2p: construct Session with Proxy instead of CService (Matthew Zipkin)d9318a37ec
net: split ConnectToSocket() from ConnectDirectly() for unix sockets (Matthew Zipkin)ac2ecf3182
proxy: rename randomize_credentials to m_randomize_credentials (Matthew Zipkin)a89c3f59dc
netbase: extend Proxy class to wrap UNIX socket as well as TCP (Matthew Zipkin)3a7d6548ef
net: move CreateSock() calls from ConnectNode() to netbase methods (Matthew Zipkin)74f568cb6f
netbase: allow CreateSock() to create UNIX sockets if supported (Matthew Zipkin)bae86c8d31
netbase: refactor CreateSock() to accept sa_family_t (Matthew Zipkin)adb3a3e51d
configure: test for unix domain sockets (Matthew Zipkin) Pull request description: Closes https://github.com/bitcoin/bitcoin/issues/27252 UNIX domain sockets are a mechanism for inter-process communication that are faster than local TCP ports (because there is no need for TCP overhead) and potentially more secure because access is managed by the filesystem instead of serving an open port on the system. There has been work on [unix domain sockets before](https://github.com/bitcoin/bitcoin/pull/9979) but for now I just wanted to start on this single use-case which is enabling unix sockets from the client side, specifically connecting to a local Tor proxy (Tor can listen on unix sockets and even enforces strict curent-user-only access permission before binding) configured by `-onion=` or `-proxy=` I copied the prefix `unix:` usage from Tor. With this patch built locally you can test with your own filesystem path (example): `tor --SocksPort unix:/Users/matthewzipkin/torsocket/x` `bitcoind -proxy=unix:/Users/matthewzipkin/torsocket/x` Prep work for this feature includes: - Moving where and how we create `sockaddr` and `Sock` to accommodate `AF_UNIX` without disturbing `CService` - Expanding `Proxy` class to represent either a `CService` or a UNIX socket (by its file path) Future work: - Enable UNIX sockets for ZMQ (https://github.com/bitcoin/bitcoin/pull/27679) - Enable UNIX sockets for I2P SAM proxy (some code is included in this PR but not tested or exposed to user options yet) - Enable UNIX sockets on windows where supported - Update Network Proxies dialog in GUI to support UNIX sockets ACKs for top commit: Sjors: re-ACK567cec9a05
tdb3: re ACK for567cec9a05
. achow101: ACK567cec9a05
vasild: ACK567cec9a05
Tree-SHA512: de81860e56d5de83217a18df4c35297732b4ad491e293a0153d2d02a0bde1d022700a1131279b187ef219651487537354b9d06d10fde56225500c7e257df92c1
This commit is contained in:
@ -158,3 +158,12 @@ def test_ipv6_local():
|
||||
except socket.error:
|
||||
have_ipv6 = False
|
||||
return have_ipv6
|
||||
|
||||
def test_unix_socket():
|
||||
'''Return True if UNIX sockets are available on this platform.'''
|
||||
try:
|
||||
socket.AF_UNIX
|
||||
except AttributeError:
|
||||
return False
|
||||
else:
|
||||
return True
|
||||
|
Reference in New Issue
Block a user