From eeb3db86386ded224d886599c836ce0b8df76234 Mon Sep 17 00:00:00 2001 From: brunneis Date: Sat, 31 Mar 2018 17:13:06 +0200 Subject: [PATCH] Support for AccountingMax and AccountingStart --- .gitignore | 1 + README.md | 13 ++++++++----- build-arch-images.sh | 2 +- dockerfile.sh | 6 +++--- entrypoint.sh | 14 +++++++++----- gen-dockerfiles.sh | 2 +- launch-relay.sh | 8 ++++++-- tor-relay-arm/arm64/Dockerfile | 2 +- tor-relay-arm/armhf/Dockerfile | 2 +- tor-relay-arm/x86-64/Dockerfile | 2 +- tor-relay/arm64/Dockerfile | 2 +- tor-relay/arm64/entrypoint.sh | 14 +++++++++----- tor-relay/armhf/Dockerfile | 2 +- tor-relay/armhf/entrypoint.sh | 14 +++++++++----- tor-relay/x86-64/Dockerfile | 2 +- tor-relay/x86-64/entrypoint.sh | 14 +++++++++----- update-relay.sh | 2 +- 17 files changed, 63 insertions(+), 39 deletions(-) diff --git a/.gitignore b/.gitignore index b25c15b..8a89cb3 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ *~ +tor-data/ diff --git a/README.md b/README.md index 35d696c..84d3aa5 100755 --- a/README.md +++ b/README.md @@ -36,11 +36,14 @@ is the tor-relay image and the second one, the relay type: Currently, it is possible to configure also the following variables when launching a dockerized relay and all of them come with default values: -- OR_PORT -- DIR_PORT -- BANDWIDTH_RATE -- BANDWIDTH_BURST -- MAX_MEM +- OR_PORT (ORPort) +- DIR_PORT (DirPort) +- CONTROL_PORT (ControlPort) +- BANDWIDTH_RATE (RelayBandwidthRate) +- BANDWIDTH_BURST (RelayBandwidthBurst) +- MAX_MEM (MaxMemInQueues) +- ACCOUNTING_MAX (AccountingMax) +- ACCOUNTING_START (AccountingStart) If you want to run a Docker image directly just set the previous environment variables and bind a volume for the Tor data as shown bellow: diff --git a/build-arch-images.sh b/build-arch-images.sh index 278947a..9b3a8c8 100755 --- a/build-arch-images.sh +++ b/build-arch-images.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay image builder -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/dockerfile.sh b/dockerfile.sh index 58f3a12..d70b5f6 100755 --- a/dockerfile.sh +++ b/dockerfile.sh @@ -1,7 +1,7 @@ #!/bin/bash # Dockerfile generator for a Tor relay image -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -26,7 +26,7 @@ TOR_VERSION=$(cat TOR_VERSION) if [ "$2" == "tor-relay" ]; then cat < +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -96,7 +96,7 @@ fi if [ "$2" == "tor-relay-arm" ]; then cat < +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/entrypoint.sh b/entrypoint.sh index 8c4f474..2044967 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay entrypoint -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ if [ "$(whoami)" == "root" ]; then useradd -s /bin/bash -u $HOST_UID tor 2> /dev/null - + if [ $? -eq 0 ]; then echo -e "export NICKNAME='${NICKNAME:-NotProvided}'\n\ export CONTACT_INFO='${CONTACT_INFO:-NotProvided}'\n\ @@ -25,10 +25,12 @@ export DIR_PORT='${DIR_PORT:-9030}'\n\ export CONTROL_PORT='${CONTROL_PORT:-9051}'\n\ export BANDWIDTH_RATE='${BANDWIDTH_RATE:-1 MBits}'\n\ export BANDWIDTH_BURST='${BANDWIDTH_BURST:-2 MBits}'\n\ -export MAX_MEM='${MAX_MEM:-512 MB}'" > /home/tor/env.sh \ +export MAX_MEM='${MAX_MEM:-512 MB}'\n\ +export ACCOUNTING_MAX='${ACCOUNTING_MAX:-0}'\n\ +export ACCOUNTING_START='${ACCOUNTING_START:-month 1 00:00}'" > /home/tor/env.sh \ && chown -R tor:tor /home/tor fi - + su -c "/entrypoint.sh $1" - tor exit fi @@ -45,7 +47,9 @@ Nickname $NICKNAME\n\ ContactInfo $CONTACT_INFO\n\ RelayBandwidthRate $BANDWIDTH_RATE\n\ RelayBandwidthBurst $BANDWIDTH_BURST\n\ -MaxMemInQueues $MAX_MEM" > $CONF_FILE +MaxMemInQueues $MAX_MEM\n\ +AccountingMax $ACCOUNTING_MAX\n\ +AccountingStart $ACCOUNTING_START" > $CONF_FILE if [ "$1" == "middle" ]; then echo -e "ExitRelay 0\n\ diff --git a/gen-dockerfiles.sh b/gen-dockerfiles.sh index ebba874..1a5625b 100755 --- a/gen-dockerfiles.sh +++ b/gen-dockerfiles.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay Dockerfile generator -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/launch-relay.sh b/launch-relay.sh index 2c1f468..657c433 100755 --- a/launch-relay.sh +++ b/launch-relay.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay launcher -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -28,8 +28,10 @@ CONTACT_INFO=not-provided@example.com BANDWIDTH_RATE="250 KBytes" BANDWIDTH_BURST="500 KBytes" MAX_MEM="512 MB" +ACCOUNTING_MAX="0" +ACCOUNTING_START="month 1 00:00" -docker run -d \ +docker run -id \ -p $OR_PORT:$OR_PORT \ -p $DIR_PORT:$DIR_PORT \ -e "OR_PORT=$OR_PORT" \ @@ -39,6 +41,8 @@ docker run -d \ -e "BANDWIDTH_RATE=$BANDWIDTH_RATE" \ -e "BANDWIDTH_BURST=$BANDWIDTH_BURST" \ -e "MAX_MEM=$MAX_MEM" \ +-e "ACCOUNTING_MAX=$ACCOUNTING_MAX" \ +-e "ACCOUNTING_START=$ACCOUNTING_START" \ -e "HOST_UID=$UID" \ -v $(pwd)/tor-data:/home/tor/data:Z \ --name tor-$2-relay $1 $2 diff --git a/tor-relay-arm/arm64/Dockerfile b/tor-relay-arm/arm64/Dockerfile index 0448ecb..7db6738 100644 --- a/tor-relay-arm/arm64/Dockerfile +++ b/tor-relay-arm/arm64/Dockerfile @@ -1,5 +1,5 @@ # Tor relay from source with ARM (Anonymizing Relay Monitor) -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tor-relay-arm/armhf/Dockerfile b/tor-relay-arm/armhf/Dockerfile index af39704..7803040 100644 --- a/tor-relay-arm/armhf/Dockerfile +++ b/tor-relay-arm/armhf/Dockerfile @@ -1,5 +1,5 @@ # Tor relay from source with ARM (Anonymizing Relay Monitor) -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tor-relay-arm/x86-64/Dockerfile b/tor-relay-arm/x86-64/Dockerfile index cd8bf95..76937d6 100644 --- a/tor-relay-arm/x86-64/Dockerfile +++ b/tor-relay-arm/x86-64/Dockerfile @@ -1,5 +1,5 @@ # Tor relay from source with ARM (Anonymizing Relay Monitor) -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tor-relay/arm64/Dockerfile b/tor-relay/arm64/Dockerfile index ae55683..9e8eb5c 100644 --- a/tor-relay/arm64/Dockerfile +++ b/tor-relay/arm64/Dockerfile @@ -1,5 +1,5 @@ # Tor relay from source -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tor-relay/arm64/entrypoint.sh b/tor-relay/arm64/entrypoint.sh index 8c4f474..2044967 100644 --- a/tor-relay/arm64/entrypoint.sh +++ b/tor-relay/arm64/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay entrypoint -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ if [ "$(whoami)" == "root" ]; then useradd -s /bin/bash -u $HOST_UID tor 2> /dev/null - + if [ $? -eq 0 ]; then echo -e "export NICKNAME='${NICKNAME:-NotProvided}'\n\ export CONTACT_INFO='${CONTACT_INFO:-NotProvided}'\n\ @@ -25,10 +25,12 @@ export DIR_PORT='${DIR_PORT:-9030}'\n\ export CONTROL_PORT='${CONTROL_PORT:-9051}'\n\ export BANDWIDTH_RATE='${BANDWIDTH_RATE:-1 MBits}'\n\ export BANDWIDTH_BURST='${BANDWIDTH_BURST:-2 MBits}'\n\ -export MAX_MEM='${MAX_MEM:-512 MB}'" > /home/tor/env.sh \ +export MAX_MEM='${MAX_MEM:-512 MB}'\n\ +export ACCOUNTING_MAX='${ACCOUNTING_MAX:-0}'\n\ +export ACCOUNTING_START='${ACCOUNTING_START:-month 1 00:00}'" > /home/tor/env.sh \ && chown -R tor:tor /home/tor fi - + su -c "/entrypoint.sh $1" - tor exit fi @@ -45,7 +47,9 @@ Nickname $NICKNAME\n\ ContactInfo $CONTACT_INFO\n\ RelayBandwidthRate $BANDWIDTH_RATE\n\ RelayBandwidthBurst $BANDWIDTH_BURST\n\ -MaxMemInQueues $MAX_MEM" > $CONF_FILE +MaxMemInQueues $MAX_MEM\n\ +AccountingMax $ACCOUNTING_MAX\n\ +AccountingStart $ACCOUNTING_START" > $CONF_FILE if [ "$1" == "middle" ]; then echo -e "ExitRelay 0\n\ diff --git a/tor-relay/armhf/Dockerfile b/tor-relay/armhf/Dockerfile index 348164c..40e6a64 100644 --- a/tor-relay/armhf/Dockerfile +++ b/tor-relay/armhf/Dockerfile @@ -1,5 +1,5 @@ # Tor relay from source -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tor-relay/armhf/entrypoint.sh b/tor-relay/armhf/entrypoint.sh index 8c4f474..2044967 100644 --- a/tor-relay/armhf/entrypoint.sh +++ b/tor-relay/armhf/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay entrypoint -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ if [ "$(whoami)" == "root" ]; then useradd -s /bin/bash -u $HOST_UID tor 2> /dev/null - + if [ $? -eq 0 ]; then echo -e "export NICKNAME='${NICKNAME:-NotProvided}'\n\ export CONTACT_INFO='${CONTACT_INFO:-NotProvided}'\n\ @@ -25,10 +25,12 @@ export DIR_PORT='${DIR_PORT:-9030}'\n\ export CONTROL_PORT='${CONTROL_PORT:-9051}'\n\ export BANDWIDTH_RATE='${BANDWIDTH_RATE:-1 MBits}'\n\ export BANDWIDTH_BURST='${BANDWIDTH_BURST:-2 MBits}'\n\ -export MAX_MEM='${MAX_MEM:-512 MB}'" > /home/tor/env.sh \ +export MAX_MEM='${MAX_MEM:-512 MB}'\n\ +export ACCOUNTING_MAX='${ACCOUNTING_MAX:-0}'\n\ +export ACCOUNTING_START='${ACCOUNTING_START:-month 1 00:00}'" > /home/tor/env.sh \ && chown -R tor:tor /home/tor fi - + su -c "/entrypoint.sh $1" - tor exit fi @@ -45,7 +47,9 @@ Nickname $NICKNAME\n\ ContactInfo $CONTACT_INFO\n\ RelayBandwidthRate $BANDWIDTH_RATE\n\ RelayBandwidthBurst $BANDWIDTH_BURST\n\ -MaxMemInQueues $MAX_MEM" > $CONF_FILE +MaxMemInQueues $MAX_MEM\n\ +AccountingMax $ACCOUNTING_MAX\n\ +AccountingStart $ACCOUNTING_START" > $CONF_FILE if [ "$1" == "middle" ]; then echo -e "ExitRelay 0\n\ diff --git a/tor-relay/x86-64/Dockerfile b/tor-relay/x86-64/Dockerfile index b8d88fe..469b677 100644 --- a/tor-relay/x86-64/Dockerfile +++ b/tor-relay/x86-64/Dockerfile @@ -1,5 +1,5 @@ # Tor relay from source -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/tor-relay/x86-64/entrypoint.sh b/tor-relay/x86-64/entrypoint.sh index 8c4f474..2044967 100644 --- a/tor-relay/x86-64/entrypoint.sh +++ b/tor-relay/x86-64/entrypoint.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay entrypoint -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ if [ "$(whoami)" == "root" ]; then useradd -s /bin/bash -u $HOST_UID tor 2> /dev/null - + if [ $? -eq 0 ]; then echo -e "export NICKNAME='${NICKNAME:-NotProvided}'\n\ export CONTACT_INFO='${CONTACT_INFO:-NotProvided}'\n\ @@ -25,10 +25,12 @@ export DIR_PORT='${DIR_PORT:-9030}'\n\ export CONTROL_PORT='${CONTROL_PORT:-9051}'\n\ export BANDWIDTH_RATE='${BANDWIDTH_RATE:-1 MBits}'\n\ export BANDWIDTH_BURST='${BANDWIDTH_BURST:-2 MBits}'\n\ -export MAX_MEM='${MAX_MEM:-512 MB}'" > /home/tor/env.sh \ +export MAX_MEM='${MAX_MEM:-512 MB}'\n\ +export ACCOUNTING_MAX='${ACCOUNTING_MAX:-0}'\n\ +export ACCOUNTING_START='${ACCOUNTING_START:-month 1 00:00}'" > /home/tor/env.sh \ && chown -R tor:tor /home/tor fi - + su -c "/entrypoint.sh $1" - tor exit fi @@ -45,7 +47,9 @@ Nickname $NICKNAME\n\ ContactInfo $CONTACT_INFO\n\ RelayBandwidthRate $BANDWIDTH_RATE\n\ RelayBandwidthBurst $BANDWIDTH_BURST\n\ -MaxMemInQueues $MAX_MEM" > $CONF_FILE +MaxMemInQueues $MAX_MEM\n\ +AccountingMax $ACCOUNTING_MAX\n\ +AccountingStart $ACCOUNTING_START" > $CONF_FILE if [ "$1" == "middle" ]; then echo -e "ExitRelay 0\n\ diff --git a/update-relay.sh b/update-relay.sh index db8efad..9d1517e 100755 --- a/update-relay.sh +++ b/update-relay.sh @@ -1,7 +1,7 @@ #!/bin/bash # Tor relay updater -# Copyright (C) 2017 Rodrigo Martínez +# Copyright (C) 2017-2018 Rodrigo Martínez # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by