aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-10-28 21:57:19 +0000
committermoneromooo-monero <moneromooo-monero@users.noreply.github.com>2020-10-28 22:38:27 +0000
commit19d1b35905a0f907230a7cc1777077e8b2f606f6 (patch)
treec9c7f0a990910ddb93d3119701fee36622d94e3b
parentMerge pull request #6902 (diff)
downloadmonero-19d1b35905a0f907230a7cc1777077e8b2f606f6.tar.xz
add a convenience script to start monero with inbound tor
Diffstat (limited to '')
-rw-r--r--README.md3
-rwxr-xr-xcontrib/tor/monero-over-tor.sh93
2 files changed, 96 insertions, 0 deletions
diff --git a/README.md b/README.md
index 2fea5385b..ec6986036 100644
--- a/README.md
+++ b/README.md
@@ -686,6 +686,9 @@ Example command line to start monerod through Tor:
DNS_PUBLIC=tcp torsocks monerod --p2p-bind-ip 127.0.0.1 --no-igd
```
+A helper script is in contrib/tor/monero-over-tor.sh. It assumes Tor is installed
+already, and runs Tor and Monero with the right configuration.
+
### Using Tor on Tails
TAILS ships with a very restrictive set of firewall rules. Therefore, you need
diff --git a/contrib/tor/monero-over-tor.sh b/contrib/tor/monero-over-tor.sh
new file mode 100755
index 000000000..9fb4cdd36
--- /dev/null
+++ b/contrib/tor/monero-over-tor.sh
@@ -0,0 +1,93 @@
+#!/bin/bash
+
+DIR=$(realpath $(dirname $0))
+
+echo "Checking monerod..."
+monerod=""
+for dir in \
+ . \
+ "$DIR" \
+ "$DIR/../.." \
+ "$DIR/build/release/bin" \
+ "$DIR/../../build/release/bin" \
+ "$DIR/build/Linux/master/release/bin" \
+ "$DIR/../../build/Linux/master/release/bin" \
+ "$DIR/build/Windows/master/release/bin" \
+ "$DIR/../../build/Windows/master/release/bin"
+do
+ if test -x "$dir/monerod"
+ then
+ monerod="$dir/monerod"
+ break
+ fi
+done
+if test -z "$monerod"
+then
+ echo "monerod not found"
+ exit 1
+fi
+echo "Found: $monerod"
+
+TORDIR="$DIR/monero-over-tor"
+TORRC="$TORDIR/torrc"
+HOSTNAMEFILE="$TORDIR/hostname"
+echo "Creating configuration..."
+mkdir -p "$TORDIR"
+chmod 700 "$TORDIR"
+rm -f "$TORRC"
+cat << EOF > "$TORRC"
+ControlSocket $TORDIR/control
+ControlSocketsGroupWritable 1
+CookieAuthentication 1
+CookieAuthFile $TORDIR/control.authcookie
+CookieAuthFileGroupReadable 1
+HiddenServiceDir $TORDIR
+HiddenServicePort 18083 127.0.0.1:18083
+EOF
+
+echo "Starting Tor..."
+nohup tor -f "$TORRC" 2> "$TORDIR/tor.stderr" 1> "$TORDIR/tor.stdout" &
+ready=0
+for i in `seq 10`
+do
+ sleep 1
+ if test -f "$HOSTNAMEFILE"
+ then
+ ready=1
+ break
+ fi
+done
+if test "$ready" = 0
+then
+ echo "Error starting Tor"
+ cat "$TORDIR/tor.stdout"
+ exit 1
+fi
+
+echo "Starting monerod..."
+HOSTNAME=$(cat "$HOSTNAMEFILE")
+"$monerod" \
+ --anonymous-inbound "$HOSTNAME":18083,127.0.0.1:18083,25 --tx-proxy tor,127.0.0.1:9050,10 \
+ --add-priority-node zbjkbsxc5munw3qusl7j2hpcmikhqocdf4pqhnhtpzw5nt5jrmofptid.onion:18083 \
+ --add-priority-node 2xmrnode5itf65lz.onion:18083 \
+ --detach
+ready=0
+for i in `seq 10`
+do
+ sleep 1
+ status=$("$monerod" status)
+ echo "$status" | grep -q "Height:"
+ if test $? = 0
+ then
+ ready=1
+ break
+ fi
+done
+if test "$ready" = 0
+then
+ echo "Error starting monerod"
+ tail -n 400 "$HOME/.bitmonero/bitmonero.log" | grep -Ev stacktrace\|"Error: Couldn't connect to daemon:"\|"src/daemon/main.cpp:.*Monero\ \'" | tail -n 20
+ exit 1
+fi
+
+echo "Ready. Your Tor hidden service is $HOSTNAME"