Skip to content

Commit

Permalink
tor: remove tor
Browse files Browse the repository at this point in the history
  • Loading branch information
willcl-ark committed Oct 30, 2023
1 parent 701745e commit ad3b5eb
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 28 deletions.
6 changes: 0 additions & 6 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ jobs:
- uses: actions/checkout@v3
- uses: ./.github/actions
- run: ./test/scenarios_test.py
onion:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: ./.github/actions
- run: ./test/v25_net_test.py
rpc:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 1 addition & 7 deletions src/interfaces/docker_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@

from .interfaces import ContainerInterface
from warnet.utils import bubble_exception_str, parse_raw_messages
from services.tor_da import TorDA
from services.fork_observer import ForkObserver
from services.fluentd import Fluentd
from services.tor_relay import TorRelay
from templates import TEMPLATES
from warnet.tank import Tank, CONTAINER_PREFIX_BITCOIND
from warnet.utils import bubble_exception_str, parse_raw_messages, default_bitcoin_conf_args, set_execute_permission
Expand Down Expand Up @@ -60,8 +58,7 @@ def build(self) -> bool:

@bubble_exception_str
def up(self):
# Give ourselves a good chance at making circuits with 10 relays
command = ["docker", "compose", "up", "--scale", "torrelay=10", "--detach"]
command = ["docker", "compose", "up", "--detach"]
try:
with subprocess.Popen(
command,
Expand Down Expand Up @@ -202,8 +199,6 @@ def _write_docker_compose(self, warnet):
# Prometheus(warnet.network_name, self.config_dir),
# NodeExporter(warnet.network_name),
# Grafana(warnet.network_name),
TorDA(warnet.network_name, TEMPLATES),
TorRelay(warnet.network_name, TEMPLATES),
ForkObserver(warnet.network_name, warnet.fork_observer_config),
Fluentd(warnet.network_name, warnet.config_dir),
]
Expand Down Expand Up @@ -269,7 +264,6 @@ def add_services(self, tank, services):
{
"container_name": tank.container_name,
"environment": {
"WARNET": "1",
"BITCOIN_ARGS": self.default_config_args(tank)
},
"networks": {
Expand Down
7 changes: 5 additions & 2 deletions src/templates/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ FROM debian:bookworm-slim
ARG UID=3338
ARG GID=3338
ARG REPO
ARG TOR=0
ARG WARNET=0
ARG BITCOIN_ARGS
# env var overrides
ENV UID=$UID
ENV GID=$GID
ENV BITCOIN_DATA=/home/bitcoin/.bitcoin
ENV BITCOIN_ARGS=$BITCOIN_ARGS
ENV TOR=$TOR
ENV WARNET=$WARNET

RUN set -ex \
&& groupadd --gid ${GID} bitcoin \
Expand All @@ -64,8 +67,8 @@ RUN set -ex \
&& apt-get install -y --no-install-recommends \
dnsutils \
gosu \
tor \
iproute2 \
tor \
&& if [ -n "${REPO}" ]; then \
apt-get install -y --no-install-recommends \
libboost-dev \
Expand All @@ -83,7 +86,7 @@ RUN set -ex \
COPY --from=builder /usr/local/bin/bitcoind /usr/local/bin/bitcoin-cli /usr/local/bin/
COPY entrypoint.sh /entrypoint.sh
# Warnet torrc using test network
COPY torrc /etc/tor/warnet-torrc
COPY torrc /etc/tor/warnet-torr

VOLUME ["/home/bitcoin/.bitcoin"]
EXPOSE 8332 8333 18332 18333 18443 18444 38333 38332
Expand Down
1 change: 0 additions & 1 deletion src/templates/bitcoin.conf
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@ rest=1

fallbackfee=0.00001000

onion=127.0.0.1:9050
listen=1
28 changes: 16 additions & 12 deletions src/templates/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,20 +1,24 @@
#!/bin/bash
set -e

# Add bitcoin user to tor group to read the auth cookie
usermod -a -G debian-tor bitcoin
# Only run this tor section if the TOR=1 env var is set
if [ "${TOR:-0}" -eq 1 ]; then

# ===========Tor setup===========
# Use custom torrc for warnet
if [ "$WARNET" -eq 1 ]; then
mv /etc/tor/warnet-torrc /etc/tor/torrc
# Add bitcoin user to tor group to read the auth cookie
usermod -a -G debian-tor bitcoin

# ===========Tor setup===========
# Use custom torrc for warnet
if [ "${WARNET:-0}" -eq 1 ]; then
mv /etc/tor/warnet-torrc /etc/tor/torrc
fi
echo "Address $(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)" >> /etc/tor/torrc
mkdir -p /home/debian-tor/.tor/keys
chown -R debian-tor:debian-tor /home/debian-tor
# Start tor in the background
gosu debian-tor tor &
# ===============================
fi
echo "Address $(ip addr show eth0 | grep "inet\b" | awk '{print $2}' | cut -d/ -f1)" >> /etc/tor/torrc
mkdir -p /home/debian-tor/.tor/keys
chown -R debian-tor:debian-tor /home/debian-tor
# Start tor in the background
gosu debian-tor tor &
# ===============================

if [ -n "${UID+x}" ] && [ "${UID}" != "0" ]; then
usermod -u "$UID" bitcoin
Expand Down

0 comments on commit ad3b5eb

Please sign in to comment.