From a605b757d094faaa0a4c6e3ea5df7f0abdf9a954 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 28 Mar 2023 22:57:26 +0200 Subject: [PATCH] base: add tor service setup and config the tor service provides hidden services for bitcoin and lightning. in the latter case, both P2P and RPC/REST. the commit also starts a new directory files. the idea is to mirror config files layout in the target system. --- apply.sh | 2 ++ base/tor.sh | 13 +++++++++++++ files/etc/tor/torrc | 19 +++++++++++++++++++ 3 files changed, 34 insertions(+) create mode 100755 base/tor.sh create mode 100644 files/etc/tor/torrc diff --git a/apply.sh b/apply.sh index ee70efb..de1a43a 100755 --- a/apply.sh +++ b/apply.sh @@ -9,6 +9,8 @@ rootdir="$SYSUPDATES_ROOTDIR" # base os cd "$rootdir" ./base/voidlinux.sh || exit 1 +cd "$rootdir" +./base/tor.sh || exit_code=$? # nakamochi daemon and gui (ndg) cd "$rootdir" diff --git a/base/tor.sh b/base/tor.sh new file mode 100755 index 0000000..0e44244 --- /dev/null +++ b/base/tor.sh @@ -0,0 +1,13 @@ +#!/bin/sh +# the script installs tor and its config file from files/etc/tor/torrc. +set -e +xbps-install -y tor +conffile=etc/tor/torrc +test -f /$conffile && diff /$conffile files/$conffile +if [ $? -ne 0 ]; then + cp /$conffile /$conffile.orig + cp files/$conffile /$conffile + ln -sfT /etc/sv/tor /var/service/tor + # don't touch the service if on manual control + test ! -f /etc/sv/tor/down && sv restart tor +fi diff --git a/files/etc/tor/torrc b/files/etc/tor/torrc new file mode 100644 index 0000000..de459bd --- /dev/null +++ b/files/etc/tor/torrc @@ -0,0 +1,19 @@ +# tor daemon configuration based on +# https://gitlab.torproject.org/tpo/core/tor/-/blob/main/src/config/torrc.sample.in +# +# NOTE: this file is auto-updated by nakamochi sysupdates +# https://git.qcode.ch/nakamochi/sysupdates + +User tor +Log notice syslog +DataDirectory /ssd/tor + +# bitcoin P2P service over tor +HiddenServiceDir /ssd/tor/bitcoind/ +HiddenServicePort 8333 127.0.0.1:8334 + +# lnd lightning P2P, RPC and REST over tor +HiddenServiceDir /ssd/tor/lnd/ +HiddenServicePort 9735 127.0.0.1:9735 +HiddenServicePort 10009 127.0.0.1:10009 +HiddenServicePort 10010 127.0.0.1:10010