HomePhabricator

net: support unix domain sockets for -proxy and -onion

Description

net: support unix domain sockets for -proxy and -onion

Summary:
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 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
  • 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

This is a backport of core#27375

Test Plan:
ninja all check-all

run the seeder

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Subscribers: Fabien

Differential Revision: https://reviews.bitcoinabc.org/D19737

Details

Provenance
Matthew Zipkin <pinheadmz@gmail.com>Authored on May 26 2023, 16:26
PiRKCommitted on Mar 27 2026, 09:16
PiRKPushed on Mar 27 2026, 09:16
Reviewer
Restricted Project
Differential Revision
D19737: net: support unix domain sockets for -proxy and -onion
Parents
rABCb18605352bbb: doc: Change documentation for =0 for non-boolean option
Branches
Unknown
Tags
Unknown