Skip to content

Commit

Permalink
Support for AccountingMax and AccountingStart
Browse files Browse the repository at this point in the history
  • Loading branch information
brunneis committed Mar 31, 2018
1 parent 12769eb commit eeb3db8
Show file tree
Hide file tree
Showing 17 changed files with 63 additions and 39 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*~
tor-data/
13 changes: 8 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion build-arch-images.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay image builder
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
6 changes: 3 additions & 3 deletions dockerfile.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Dockerfile generator for a Tor relay image
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand All @@ -26,7 +26,7 @@ TOR_VERSION=$(cat TOR_VERSION)
if [ "$2" == "tor-relay" ]; then
cat <<EOF
# Tor relay from source
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down Expand Up @@ -96,7 +96,7 @@ fi
if [ "$2" == "tor-relay-arm" ]; then
cat <<EOF
# Tor relay from source with ARM (Anonymizing Relay Monitor)
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
14 changes: 9 additions & 5 deletions entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay entrypoint
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand All @@ -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\
Expand All @@ -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
Expand All @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion gen-dockerfiles.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay Dockerfile generator
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
8 changes: 6 additions & 2 deletions launch-relay.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay launcher
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand All @@ -28,8 +28,10 @@ [email protected]
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" \
Expand All @@ -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
2 changes: 1 addition & 1 deletion tor-relay-arm/arm64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tor relay from source with ARM (Anonymizing Relay Monitor)
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
2 changes: 1 addition & 1 deletion tor-relay-arm/armhf/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tor relay from source with ARM (Anonymizing Relay Monitor)
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
2 changes: 1 addition & 1 deletion tor-relay-arm/x86-64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tor relay from source with ARM (Anonymizing Relay Monitor)
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
2 changes: 1 addition & 1 deletion tor-relay/arm64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tor relay from source
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
14 changes: 9 additions & 5 deletions tor-relay/arm64/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay entrypoint
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand All @@ -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\
Expand All @@ -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
Expand All @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion tor-relay/armhf/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tor relay from source
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
14 changes: 9 additions & 5 deletions tor-relay/armhf/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay entrypoint
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand All @@ -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\
Expand All @@ -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
Expand All @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion tor-relay/x86-64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Tor relay from source
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down
14 changes: 9 additions & 5 deletions tor-relay/x86-64/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay entrypoint
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand All @@ -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\
Expand All @@ -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
Expand All @@ -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\
Expand Down
2 changes: 1 addition & 1 deletion update-relay.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

# Tor relay updater
# Copyright (C) 2017 Rodrigo Martínez <[email protected]>
# Copyright (C) 2017-2018 Rodrigo Martínez <[email protected]>
#
# 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
Expand Down

0 comments on commit eeb3db8

Please sign in to comment.