Environment variables (#331)

* Adding relay name env variable and env variables description in markdown file

* Fixing env variable usage and adding relay type env variable

* Adding bandwidth related environment variables
This commit is contained in:
Aurélien JANVIER 2018-06-06 23:04:18 +02:00 committed by Jess Frazelle
parent db6699304d
commit 3cdd8ce273
6 changed files with 46 additions and 7 deletions

View File

@ -31,6 +31,16 @@ COPY torrc.bridge /etc/tor/torrc.bridge
COPY torrc.middle /etc/tor/torrc.middle COPY torrc.middle /etc/tor/torrc.middle
COPY torrc.exit /etc/tor/torrc.exit COPY torrc.exit /etc/tor/torrc.exit
# copy the run script
COPY run.sh /run.sh
RUN chmod u+rwx /run.sh
# default environment variables
ENV RELAY_NICKNAME hacktheplanet
ENV RELAY_TYPE middle
ENV RELAY_BANDWIDTH_RATE 100 KBytes
ENV RELAY_BANDWIDTH_BURST 200 KBytes
# make sure files are owned by tor user # make sure files are owned by tor user
RUN chown -R tor /etc/tor RUN chown -R tor /etc/tor
@ -40,4 +50,4 @@ RUN mkdir /var/lib/tor/.tor
VOLUME /var/lib/tor/.tor VOLUME /var/lib/tor/.tor
RUN chown -R tor /var/lib/tor/.tor RUN chown -R tor /var/lib/tor/.tor
ENTRYPOINT [ "tor" ] ENTRYPOINT [ "/run.sh" ]

11
tor-relay/README.md Normal file
View File

@ -0,0 +1,11 @@
### Environment variables
| Name | Description | Default value |
| ---------------------------- |:----------------------------------------------------------------------------:| -------------:|
| **RELAY_TYPE** | The type of relay (bridge, middle or exit) | middle |
| **RELAY_NICKNAME** | The nickname of your relay | hacktheplanet |
| **CONTACT_GPG_FINGERPRINT** | Your GPG ID or fingerprint | none |
| **CONTACT_NAME** | Your name | none |
| **CONTACT_EMAIL** | Your contact email | none |
| **RELAY_BANDWIDTH_RATE** | Limit how much traffic will be allowed through your relay (must be > 20KB/s) | 100 KBytes |
| **RELAY_BANDWIDTH_BURST** | Allow temporary bursts up to a certain amount | 200 KBytes |

12
tor-relay/run.sh Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
for relaytype in bridge middle exit; do
sed -i 's/${RELAY_NICKNAME}/'"$RELAY_NICKNAME"'/g' "/etc/tor/torrc.$relaytype"
sed -i 's/${CONTACT_GPG_FINGERPRINT}/'"$CONTACT_GPG_FINGERPRINT"'/g' "/etc/tor/torrc.$relaytype"
sed -i 's/${CONTACT_NAME}/'"$CONTACT_NAME"'/g' "/etc/tor/torrc.$relaytype"
sed -i 's/${CONTACT_EMAIL}/'"$CONTACT_EMAIL"'/g' "/etc/tor/torrc.$relaytype"
sed -i 's/${RELAY_BANDWIDTH_RATE}/'"$RELAY_BANDWIDTH_RATE"'/g' "/etc/tor/torrc.$relaytype"
sed -i 's/${RELAY_BANDWIDTH_BURST}/'"$RELAY_BANDWIDTH_BURST"'/g' "/etc/tor/torrc.$relaytype"
done
tor -f /etc/tor/torrc.${RELAY_TYPE}

View File

@ -97,7 +97,7 @@ ORPort 9001
# OutboundBindAddress 10.0.0.5 # OutboundBindAddress 10.0.0.5
## A handle for your relay, so people don't have to refer to it by key. ## A handle for your relay, so people don't have to refer to it by key.
Nickname hacktheplanet Nickname ${RELAY_NICKNAME}
## Define these to limit how much relayed traffic you will allow. Your ## Define these to limit how much relayed traffic you will allow. Your
## own traffic is still unthrottled. Note that RelayBandwidthRate must ## own traffic is still unthrottled. Note that RelayBandwidthRate must
@ -107,6 +107,8 @@ Nickname hacktheplanet
## 2^20, etc. ## 2^20, etc.
#RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps) #RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps)
#RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb) #RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb)
RelayBandwidthRate ${RELAY_BANDWIDTH_RATE}
RelayBandwidthBurst ${RELAY_BANDWIDTH_BURST}
## Use these to restrict the maximum traffic per day, week, or month. ## Use these to restrict the maximum traffic per day, week, or month.
## Note that this threshold applies separately to sent and received bytes, ## Note that this threshold applies separately to sent and received bytes,

View File

@ -97,7 +97,7 @@ ORPort 9001
# OutboundBindAddress 10.0.0.5 # OutboundBindAddress 10.0.0.5
## A handle for your relay, so people don't have to refer to it by key. ## A handle for your relay, so people don't have to refer to it by key.
Nickname hacktheplanet Nickname ${RELAY_NICKNAME}
## Define these to limit how much relayed traffic you will allow. Your ## Define these to limit how much relayed traffic you will allow. Your
## own traffic is still unthrottled. Note that RelayBandwidthRate must ## own traffic is still unthrottled. Note that RelayBandwidthRate must
@ -107,6 +107,8 @@ Nickname hacktheplanet
## 2^20, etc. ## 2^20, etc.
#RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps) #RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps)
#RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb) #RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb)
RelayBandwidthRate ${RELAY_BANDWIDTH_RATE}
RelayBandwidthBurst ${RELAY_BANDWIDTH_BURST}
## Use these to restrict the maximum traffic per day, week, or month. ## Use these to restrict the maximum traffic per day, week, or month.
## Note that this threshold applies separately to sent and received bytes, ## Note that this threshold applies separately to sent and received bytes,

View File

@ -97,7 +97,7 @@ ORPort 9001
# OutboundBindAddress 10.0.0.5 # OutboundBindAddress 10.0.0.5
## A handle for your relay, so people don't have to refer to it by key. ## A handle for your relay, so people don't have to refer to it by key.
Nickname hacktheplanet Nickname ${RELAY_NICKNAME}
## Define these to limit how much relayed traffic you will allow. Your ## Define these to limit how much relayed traffic you will allow. Your
## own traffic is still unthrottled. Note that RelayBandwidthRate must ## own traffic is still unthrottled. Note that RelayBandwidthRate must
@ -107,6 +107,8 @@ Nickname hacktheplanet
## 2^20, etc. ## 2^20, etc.
#RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps) #RelayBandwidthRate 100 KBytes # Throttle traffic to 100KB/s (800Kbps)
#RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb) #RelayBandwidthBurst 200 KBytes # But allow bursts up to 200KB (1600Kb)
RelayBandwidthRate ${RELAY_BANDWIDTH_RATE}
RelayBandwidthBurst ${RELAY_BANDWIDTH_BURST}
## Use these to restrict the maximum traffic per day, week, or month. ## Use these to restrict the maximum traffic per day, week, or month.
## Note that this threshold applies separately to sent and received bytes, ## Note that this threshold applies separately to sent and received bytes,