-
Notifications
You must be signed in to change notification settings - Fork 37.7k
net: support unix domain sockets for -proxy and -onion #27375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code CoverageFor detailed information about the code coverage, see the test coverage report. ReviewsSee the guideline for information on the review process.
If your review is incorrectly listed, please react with 👎 to this comment and the bot will ignore it on the next update. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
73d2c56
to
7785e4d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
With some light testing it seems to work pretty nicely:
will@ubuntu in ~/src/bitcoin on tor-unix-domain-socket [$?] via 🐍 3.7.16 took 6s
₿ sudo exa -al /proc/(pidof bitcoind)/fd
lrwx------ 64 will 31 Mar 09:21 0 -> /dev/null
lrwx------ 64 will 31 Mar 09:21 1 -> /dev/null
lrwx------ 64 will 31 Mar 09:21 2 -> /dev/null
lr-x------ 64 will 31 Mar 09:21 3 -> pipe:[47084978]
l-wx------ 64 will 31 Mar 09:21 4 -> pipe:[47084978]
lrwx------ 64 will 31 Mar 09:21 5 -> /home/will/.bitcoin/signet/.lock
l-wx------ 64 will 31 Mar 09:21 6 -> /home/will/.bitcoin/signet/debug.log
lrwx------ 64 will 31 Mar 09:21 7 -> anon_inode:[eventpoll]
lr-x------ 64 will 31 Mar 09:21 8 -> pipe:[47101090]
l-wx------ 64 will 31 Mar 09:21 9 -> pipe:[47101090]
lrwx------ 64 will 31 Mar 09:21 10 -> anon_inode:[eventfd]
lrwx------@ 64 will 31 Mar 09:21 11 -> socket:[47101093]
lrwx------@ 64 will 31 Mar 09:21 12 -> socket:[47101095]
lrwx------ 64 will 31 Mar 09:21 13 -> /home/will/.bitcoin/signet/blocks/index/LOCK
l-wx------ 64 will 31 Mar 09:21 14 -> /home/will/.bitcoin/signet/blocks/index/000387.log
l-wx------ 64 will 31 Mar 09:21 15 -> /home/will/.bitcoin/signet/blocks/index/MANIFEST-000385
lrwx------ 64 will 31 Mar 09:21 16 -> /home/will/.bitcoin/signet/chainstate/LOCK
l-wx------ 64 will 31 Mar 09:21 17 -> /home/will/.bitcoin/signet/chainstate/002594.log
l-wx------ 64 will 31 Mar 09:21 18 -> /home/will/.bitcoin/signet/chainstate/MANIFEST-002593
lrwx------ 64 will 31 Mar 09:21 19 -> /home/will/.bitcoin/signet/wallets/legacy/.walletlock
l-wx------ 64 will 31 Mar 09:21 20 -> /home/will/.bitcoin/signet/wallets/legacy/db.log
lrwx------ 64 will 31 Mar 09:21 21 -> /home/will/.bitcoin/signet/wallets/legacy/wallet.dat
lrwx------ 64 will 31 Mar 09:21 22 -> /home/will/.bitcoin/signet/wallets/legacy/database/log.0000000001
lrwx------ 64 will 31 Mar 09:21 23 -> /home/will/.bitcoin/signet/wallets/test-descriptor/wallet.dat
lrwx------ 64 will 31 Mar 09:21 24 -> /home/will/.bitcoin/signet/wallets/test-descriptor/wallet.dat-journal
lrwx------ 64 will 31 Mar 09:21 25 -> anon_inode:[eventpoll]
lr-x------ 64 will 31 Mar 09:21 26 -> pipe:[47084995]
l-wx------ 64 will 31 Mar 09:21 27 -> pipe:[47084995]
lrwx------ 64 will 31 Mar 09:21 28 -> anon_inode:[eventfd]
lrwx------@ 64 will 31 Mar 09:21 29 -> socket:[47099059]
lrwx------@ 64 will 31 Mar 09:21 30 -> socket:[47084996]
lrwx------@ 64 will 31 Mar 09:21 31 -> socket:[47084997]
lrwx------@ 64 will 31 Mar 09:21 32 -> socket:[47099065]
lrwx------@ 64 will 31 Mar 09:21 33 -> socket:[47084998]
lrwx------@ 64 will 31 Mar 09:21 34 -> socket:[47100197]
lrwx------@ 64 will 31 Mar 09:21 35 -> socket:[47099299]
lrwx------@ 64 will 31 Mar 09:21 36 -> socket:[47099533]
lrwx------@ 64 will 31 Mar 09:22 37 -> socket:[47099588]
lrwx------@ 64 will 31 Mar 09:22 38 -> socket:[47085043]
lrwx------@ 64 will 31 Mar 09:22 39 -> socket:[47085047]
With new socket connections being opened for each connection.
As I mentioned in one of my comments, I am curious why you didn't go for the -onion
case too, to reduce the scope of the change?
Enabling -onion
in the PortErrorMessage
check loop did appear to also work nicely (although i did not check whether there were any other side-effects).
The info shown by -netinfo 4
looked correct in both cases.
7785e4d
to
4128840
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback @willcl-ark. force-push to 2436b00 should address your notes. I'm still expecting some CI failures from platforms that don't support unix sockets, then I'll add configure options like wumpus did here
261ce7e
to
2436b00
Compare
0d19a39
to
3436ddb
Compare
3436ddb
to
502db51
Compare
0267cfe
to
44dd4cb
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK, this would be nice to have.
I do not like that the current approach expands enum Network
and CNetAddr
with the UNIX type, making it first-class-citizen network that has to be handled all over the networking code, whereas it is only needed to connect to the proxy. It is not like this PR adds support for connecting to other Bitcoin nodes over UNIX sockets (using the P2P protocol). This creates meaningless situations like having a CService
on a UNIX socket (it is meaningless because CService
has port, whereas UNIX sockets don't have port). Similarly CSubNet
on a UNIX socket is meaningless.
I will play a bit with this to see if it would be possible to constrain the logic in the Proxy
class and hide from the rest of the code whether the proxy is at addr:port
or unix:/path
.
44dd4cb
to
3ea142e
Compare
Thanks so much for the great review @vasild I think I addressed all your feedback up to the adding UNIX to CNetAddr. I understand your concerns there and we can chat about it, I'll look at alternatives as well. What I did do in this last push was mostly separate unix sockets from regular sockets, and adding |
3ea142e
to
7008e8f
Compare
7008e8f
to
2c19dd7
Compare
Is the expectation here that we should see a lot more |
Yes but that log message can be removed or set to debug in a follow-up. With
I have a few unix sockets follow ups planned: RPC & bitcoin-cli (maybe speed up the tests!) and ZMQ. I'll clean up this log message in those |
Ok, it needs to be cleaned up because it's just spammy/pointless. i.e: 2024-03-13T13:26:00Z Cannot connect to socket for 151.213.177.128:8333
2024-03-13T13:26:24Z Cannot connect to socket for 75.88.65.59:8333
2024-03-13T13:26:48Z Cannot connect to socket for 76.114.61.112:8333
2024-03-13T13:28:55Z Cannot connect to socket for [2600:8805:5c26:eb00:61b0:c6a7:451:1b39]:8333
2024-03-13T13:30:45Z New block-relay-only v1 peer connected: version: 70016, blocks=834513, peer=39
2024-03-13T13:32:01Z Cannot connect to socket for [2a04:6ec0:20d:d050:819a:ceb8:4416:2bc0]:8333
2024-03-13T13:32:14Z New block-relay-only v1 peer connected: version: 70016, blocks=834513, peer=40
2024-03-13T13:34:47Z New block-relay-only v1 peer connected: version: 70016, blocks=834513, peer=41
2024-03-13T13:34:58Z Cannot connect to socket for 122.206.190.60:8333
2024-03-13T13:36:23Z New block-relay-only v1 peer connected: version: 70016, blocks=834513, peer=42
2024-03-13T13:37:38Z Cannot connect to socket for 138.199.60.26:8333
2024-03-13T13:38:34Z Cannot connect to socket for 120.236.171.239:8333
2024-03-13T13:39:00Z Cannot connect to socket for 35.72.149.104:8333
2024-03-13T13:41:22Z Cannot connect to socket for 176.199.211.63:8333
2024-03-13T13:41:25Z Cannot connect to socket for [2804:7f0:7c80:196f:b0b2:1642:e4a9:b794]:8333
2024-03-13T13:41:37Z Cannot connect to socket for [2a00:b700::3:379]:8333
2024-03-13T13:42:55Z Cannot connect to socket for [2001:871:24b:ab3e:d1f2:1f7e:b950:692f]:8333
2024-03-13T13:43:01Z New block-relay-only v1 peer connected: version: 70016, blocks=834513, peer=43
2024-03-13T13:45:30Z Cannot connect to socket for 121.237.138.96:8333
2024-03-13T13:46:56Z Cannot connect to socket for 110.153.86.87:8333
2024-03-13T13:48:32Z Saw new header hash=0000000000000000000071923ef5a18dc17d47717fae386296dfe8902414ea71 height=834514
2024-03-13T13:48:32Z Saw new cmpctblock header hash=0000000000000000000071923ef5a18dc17d47717fae386296dfe8902414ea71 peer=16
2024-03-13T13:48:32Z UpdateTip: new best=0000000000000000000071923ef5a18dc17d47717fae386296dfe8902414ea71 height=834514 version=0x2fffe000 log2_work=94.792163 tx=976064192 date='2024-03-13T13:48:27Z' progress=1.000000 cache=232.4MiB(1767736txo)
2024-03-13T13:50:28Z Cannot connect to socket for 58.219.96.208:8333
2024-03-13T13:50:41Z Cannot connect to socket for 189.19.183.194:8333
2024-03-13T13:52:56Z New block-relay-only v1 peer connected: version: 70016, blocks=834514, peer=45
2024-03-13T13:53:12Z Cannot connect to socket for [2600:381:6a90:cfa5:b0a4:5c43:fdb8:9298]:8333
2024-03-13T13:56:25Z Cannot connect to socket for [2003:d7:df24:a900:53a3:8916:d525:9958]:8333
2024-03-13T14:00:04Z Cannot connect to socket for 97.96.100.48:8333
2024-03-13T14:03:56Z Cannot connect to socket for 195.181.167.197:8333
2024-03-13T14:04:02Z Saw new header hash=00000000000000000001ee20083bb8df96e256bb46dd856c48f686b692dbc29b height=834515
2024-03-13T14:04:02Z Saw new cmpctblock header hash=00000000000000000001ee20083bb8df96e256bb46dd856c48f686b692dbc29b peer=16
2024-03-13T14:04:02Z UpdateTip: new best=00000000000000000001ee20083bb8df96e256bb46dd856c48f686b692dbc29b height=834515 version=0x294c8000 log2_work=94.792178 tx=976067423 date='2024-03-13T14:03:37Z' progress=1.000000 cache=234.9MiB(1785815txo)
2024-03-13T14:04:31Z Cannot connect to socket for [2606:6080:1001:30:5f94:f242:c829:1017]:8333
2024-03-13T14:04:32Z Saw new header hash=00000000000000000001cee842398455cae402ab13037a450fe4829db7efd2e2 height=834516
2024-03-13T14:04:32Z Saw new cmpctblock header hash=00000000000000000001cee842398455cae402ab13037a450fe4829db7efd2e2 peer=16
2024-03-13T14:04:33Z UpdateTip: new best=00000000000000000001cee842398455cae402ab13037a450fe4829db7efd2e2 height=834516 version=0x27fd4000 log2_work=94.792192 tx=976069773 date='2024-03-13T14:04:13Z' progress=1.000000 cache=236.4MiB(1799558txo)
2024-03-13T14:04:59Z Cannot connect to socket for 178.70.102.186:8333
2024-03-13T14:05:43Z Cannot connect to socket for [2409:8a55:6ad:7101:49d4:4737:ccad:17c]:8333
2024-03-13T14:06:21Z Saw new header hash=000000000000000000030739bcd83bfdfc6a03a1a58e21e4c61d6b59ac047569 height=834517
2024-03-13T14:06:21Z Saw new cmpctblock header hash=000000000000000000030739bcd83bfdfc6a03a1a58e21e4c61d6b59ac047569 peer=16
2024-03-13T14:06:21Z UpdateTip: new best=000000000000000000030739bcd83bfdfc6a03a1a58e21e4c61d6b59ac047569 height=834517 version=0x2cbea000 log2_work=94.792206 tx=976071288 date='2024-03-13T14:05:33Z' progress=1.000000 cache=236.4MiB(1802022txo)
2024-03-13T14:06:45Z Cannot connect to socket for 86.168.50.224:8333
2024-03-13T14:08:29Z Cannot connect to socket for 194.163.131.91:39388
2024-03-13T14:11:12Z Cannot connect to socket for [2603:6080:7a0e:59ff:9da7:4932:3d76:58ec]:8333
2024-03-13T14:11:41Z Cannot connect to socket for 108.214.8.13:60501
2024-03-13T14:12:06Z Cannot connect to socket for 84.178.138.51:8333 |
c70e4fc netbase: remove unnecessary log message (Matthew Zipkin) Pull request description: This is a follow-up to #27375 that removes a spammy non-debug-level log message we don't need. See #27375 (comment) ACKs for top commit: fanquake: ACK c70e4fc - thanks. Merging this now because it's swamping non-debug logs. i.e: Tree-SHA512: 837682860abdf740fce5dc88c8599e066660cf16b4cab1473391eb51ad538ae52d236ecd3543df866e2a2165870397a8bf21ad9f5125ed8212a3fe207d615553
be04ac9 fixup! cmake: Check system symbols (Hennadii Stepanov) 4ff1257 fixup! cmake: Check system symbols (Hennadii Stepanov) Pull request description: This PR: 1) Backports changes from bitcoin#27375. 2) Aligns symbol checks with bitcoin#27699. A possible way to review this PR and the whole symbol check logic is to observe the Autotools vs CMake diff in the `config/bitcoin-config.h`: ``` ./autogen.sh ./configure cmake -B build diff -u src/config/bitcoin-config.h build/src/config/bitcoin-config.h ``` ACKs for top commit: TheCharlatan: ACK be04ac9 Tree-SHA512: 71bde1e3133ae1550b2948991782173ee85913a4746d7195ed0ce79cd2106997f9127b35826b2ac848cdfaba73d604bd2567e129103e11e5f0d6163af59f5845
List of the squashed commits: ============================= cmake: Add root `CMakeLists.txt` file cmake: Introduce core interface libraries to encapsulate common flags Also add a sanity check for non-encapsulated (directory-wide) build properties. cmake: Add `config/bitcoin-config.h` support cmake: Check system headers cmake: Check system symbols Co-authored-by: Cory Fields <cory-nospam-@coryfields.com> Co-authored-by: Vasil Dimov <vd@FreeBSD.org> cmake: Check compiler features cmake: Add position independent code support cmake: Add platform-specific definitions and properties cmake: Build `crc32c` static library cmake: Build `leveldb` static library Co-authored-by: Cory Fields <cory-nospam-@coryfields.com> cmake: Build `minisketch` static library cmake: Build `secp256k1` static library cmake: Build `univalue` static library cmake: Build `bitcoin_crypto` library cmake: Build `bitcoin_util` static library cmake: Build `bitcoin_consensus` library cmake: Build `bitcoind` executable depends: Amend handling flags environment variables If any of {C,CXX,CPP,LD}FLAGS is specified it should be assigned to a non-type-specific variable. build: Generate `share/toolchain.cmake` in depends cmake: Add cross-compiling support To configure CMake for cross-compiling, use `--toolchain depends/${HOST}/share/toolchain.cmake` command-line option. cmake: Add `TristateOption` module cmake: Add `ccache` support cmake: Add `libnatpmp` optional package support cmake: Add `libminiupnpc` optional package support cmake: Add `libzmq` optional package support cmake: Add `systemtap-sdt` optional package support cmake: Build `bitcoin-cli` executable cmake: Build `bitcoin-tx` executable cmake: Build `bitcoin-util` executable cmake: Add wallet functionality cmake: Add test config and runners cmake: Build `bench_bitcoin` executable cmake: Build `test_bitcoin` executable cmake: Include CTest cmake: Add `TryAppendCXXFlags` module cmake: Add `TryAppendLinkerFlag` module cmake: Add platform-specific compiler flags cmake: Add platform-specific linker flags cmake: Redefine/adjust per-configuration flags cmake: Add general compile options cmake: Add `HARDENING` option cmake: Add `REDUCE_EXPORTS` option cmake: Add `WERROR` option cmake: Implement `make install` cmake: Generate `obj/build.h` header cmake: Add `GenerateBuildInfo.cmake` script Revert "build, qt: Do not install *.prl files" This reverts commit 1155978. qt, build: Drop `QT_STATICPLUGIN` macro Our `QT_STATICPLUGIN` macro is effectively equivalent to the Qt's `QT_STATIC` macro. No need to handle both of them. cmake: Build `bitcoin-qt` executable cmake: Build `test_bitcoin-qt` executable qt: Drop `Q_IMPORT_PLUGIN` macros When using CMake, each plugin comes with a C++ stub file that automatically initializes the static plugin. Consequently, any target that links against a plugin has this C++ file added to its SOURCES, which makes the removed code redundant. cmake: Add `libqrencode` optional package support cmake: Add `SANITIZERS` option cmake: Add external signer support cmake: Add fuzzing options cmake: Add `AddWindowsResources` module cmake: Add `Maintenance` module cmake: Migrate Guix build scripts to CMake cmake: Add vcpkg manifest file cmake: Add preset for MSVC build Fix MSVC warning C4273 "inconsistent dll linkage" cmake, doc: Update `release-process.md` Only versioning has been updated for now. cmake: Add compiler diagnostic flags test: Fix MSVC warning C4101 "unreferenced local variable" ci: Test CMake edge cases Keep this commit at the top when rebasing. Add macOS cross compile jobs. Don't pass `-fno-extended-identifiers` to a linker Process linker flags properly. refactor! cmake: Redefine/adjust per-configuration flags Process linker flags properly. Add `deploy` target for macOS Add the missing source file. See: bitcoin#28578 Backport bitcoin#27375. Align with bitcoin#27699.
List of the squashed commits: ============================= cmake: Add root `CMakeLists.txt` file cmake: Introduce core interface libraries to encapsulate common flags Also add a sanity check for non-encapsulated (directory-wide) build properties. cmake: Add `config/bitcoin-config.h` support cmake: Check system headers cmake: Check system symbols Co-authored-by: Cory Fields <cory-nospam-@coryfields.com> Co-authored-by: Vasil Dimov <vd@FreeBSD.org> cmake: Check compiler features cmake: Add position independent code support cmake: Add platform-specific definitions and properties cmake: Build `crc32c` static library cmake: Build `leveldb` static library Co-authored-by: Cory Fields <cory-nospam-@coryfields.com> cmake: Build `minisketch` static library cmake: Build `secp256k1` static library cmake: Build `univalue` static library cmake: Build `bitcoin_crypto` library cmake: Build `bitcoin_util` static library cmake: Build `bitcoin_consensus` library cmake: Build `bitcoind` executable depends: Amend handling flags environment variables If any of {C,CXX,CPP,LD}FLAGS is specified it should be assigned to a non-type-specific variable. build: Generate `share/toolchain.cmake` in depends cmake: Add cross-compiling support To configure CMake for cross-compiling, use `--toolchain depends/${HOST}/share/toolchain.cmake` command-line option. cmake: Add `TristateOption` module cmake: Add `ccache` support cmake: Add `libnatpmp` optional package support cmake: Add `libminiupnpc` optional package support cmake: Add `libzmq` optional package support cmake: Add `systemtap-sdt` optional package support cmake: Build `bitcoin-cli` executable cmake: Build `bitcoin-tx` executable cmake: Build `bitcoin-util` executable cmake: Add wallet functionality cmake: Add test config and runners cmake: Build `bench_bitcoin` executable cmake: Build `test_bitcoin` executable cmake: Include CTest cmake: Add `TryAppendCXXFlags` module cmake: Add `TryAppendLinkerFlag` module cmake: Add platform-specific compiler flags cmake: Add platform-specific linker flags cmake: Redefine/adjust per-configuration flags cmake: Add general compile options cmake: Add `HARDENING` option cmake: Add `REDUCE_EXPORTS` option cmake: Add `WERROR` option cmake: Implement `make install` cmake: Generate `obj/build.h` header cmake: Add `GenerateBuildInfo.cmake` script Revert "build, qt: Do not install *.prl files" This reverts commit 1155978. qt, build: Drop `QT_STATICPLUGIN` macro Our `QT_STATICPLUGIN` macro is effectively equivalent to the Qt's `QT_STATIC` macro. No need to handle both of them. cmake: Build `bitcoin-qt` executable cmake: Build `test_bitcoin-qt` executable qt: Drop `Q_IMPORT_PLUGIN` macros When using CMake, each plugin comes with a C++ stub file that automatically initializes the static plugin. Consequently, any target that links against a plugin has this C++ file added to its SOURCES, which makes the removed code redundant. cmake: Add `libqrencode` optional package support cmake: Add `SANITIZERS` option cmake: Add external signer support cmake: Add fuzzing options cmake: Add `AddWindowsResources` module cmake: Add `Maintenance` module cmake: Migrate Guix build scripts to CMake cmake: Add vcpkg manifest file cmake: Add preset for MSVC build Fix MSVC warning C4273 "inconsistent dll linkage" cmake, doc: Update `release-process.md` Only versioning has been updated for now. cmake: Add compiler diagnostic flags test: Fix MSVC warning C4101 "unreferenced local variable" ci: Test CMake edge cases Keep this commit at the top when rebasing. Add macOS cross compile jobs. Don't pass `-fno-extended-identifiers` to a linker Process linker flags properly. refactor! cmake: Redefine/adjust per-configuration flags Process linker flags properly. Add `deploy` target for macOS Add the missing source file. See: bitcoin#28578 Backport bitcoin#27375. Align with bitcoin#27699.
21d0e6c doc: release notes for PR 27679 (Matthew Zipkin) 791dea2 test: cover unix sockets in zmq interface (Matthew Zipkin) c87b0a0 zmq: accept unix domain socket address for notifier (Matthew Zipkin) Pull request description: This is a follow-up to #27375, allowing ZMQ notifications to be published to a UNIX domain socket. Fortunately, libzmq handles unix sockets already, all we really have to do to support it is allow the format in the actual option. [libzmq](https://libzmq.readthedocs.io/en/latest/zmq_ipc.html) uses the prefix `ipc://` as opposed to `unix:` which is [used by Tor](https://gitlab.torproject.org/tpo/core/tor/-/blob/main/doc/man/tor.1.txt?ref_type=heads#L1475) and now also by [bitcoind](https://github.com/bitcoin/bitcoin/blob/a85e5a7c9ab75209bc88e49be6991ba0a467034e/doc/release-notes-27375.md?plain=1#L5) so we need to switch that internally. As far as I can tell, [LND](https://github.com/lightninglabs/gozmq/blob/d20a764486bf506bc045642e455bc7f0d21b232a/zmq.go#L38) supports `ipc://` and `unix://` (notice the double slashes). With this patch, LND can connect to bitcoind using unix sockets: Example: *bitcoin.conf*: ``` zmqpubrawblock=unix:/tmp/zmqsb zmqpubrawtx=unix:/tmp/zmqst ``` *lnd.conf*: ``` bitcoind.zmqpubrawblock=ipc:///tmp/zmqsb bitcoind.zmqpubrawtx=ipc:///tmp/zmqst ``` ACKs for top commit: laanwj: Code review ACK 21d0e6c tdb3: crACK for 21d0e6c. Changes lgtm. Will follow up with some testing within the next few days as time allows. achow101: ACK 21d0e6c guggero: Tested and code review ACK 21d0e6c Tree-SHA512: ffd50222e80dd029d903e5ddde37b83f72dfec1856a3f7ce49da3b54a45de8daaf80eea1629a30f58559f4b8ded0b29809548c0638cd1c2811b2736ad8b73030
fb4cc5f netbase: clean up Proxy logging (Matthew Zipkin) Pull request description: Follow up to #27375 and see #29649 (comment) This removes an extra log message when we can't connect to our own proxy, and another when the proxy is invalid. ## Before #27375 if proxy is unreachable ``` 2024-04-15T17:54:51Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61) 2024-04-15T17:54:52Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61) 2024-04-15T17:54:52Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61) 2024-04-15T17:54:53Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61) 2024-04-15T17:54:53Z connect() to 127.0.0.1:9999 failed after wait: Connection refused (61) ``` ## After #27375 if unix proxy is unreachable: ``` 2024-04-15T17:54:03Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) 2024-04-15T17:54:03Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor 2024-04-15T17:54:04Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) 2024-04-15T17:54:04Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor 2024-04-15T17:54:04Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) 2024-04-15T17:54:04Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor 2024-04-15T17:54:05Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) 2024-04-15T17:54:05Z Cannot connect to socket for /Users/matthewzipkin/Desktop/tor ``` ## After this PR: ``` 2024-04-15T18:18:51Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) 2024-04-15T18:18:51Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) 2024-04-15T18:18:52Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) 2024-04-15T18:18:52Z connect() to /Users/matthewzipkin/Desktop/tor failed: No such file or directory (2) ``` ACKs for top commit: tdb3: CR ACK for fb4cc5f laanwj: ACK fb4cc5f Tree-SHA512: f07b9f7f2ea9f4bc01780c09f0b076547108294a1fa7d158a0dd48d6d7351569e461e5cccf232b7b1413ce2e3679668e523e5a7c89cd58c909da76d3dcbc34de
Part of "extend Proxy class to wrap UNIX socket as well as TCP" Github-Pull: bitcoin#27375 Commit: a89c3f5
Part of "test: cover UNIX sockets in feature_proxy.py" Github-Pull: bitcoin#27375 Commit: bfe5192
Closes #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 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:
sockaddr
andSock
to accommodateAF_UNIX
without disturbingCService
Proxy
class to represent either aCService
or a UNIX socket (by its file path)Future work: