Skip to content

Commit

Permalink
Enable includes and add TORRC_APPEND
Browse files Browse the repository at this point in the history
  • Loading branch information
thomasleplus committed Nov 2, 2024
1 parent 53f1b15 commit 48fa1a8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
15 changes: 8 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,14 @@ variables. You can set a custom value for these variables for example
using the `-e` option of Docker. Below are the variables currently
available:

| Variable name | Usage | Default |
| -------------- | ----------------------- | ------------ |
| DATA_DIRECTORY | The data directory. | /var/lib/tor |
| LOG_LEVEL | The logging level. | notice |
| LOG_FILE | The log file or device. | stdout |
| SOCKS_HOSTNAME | The SOCKS hostname. | 127.0.0.0.1 |
| SOCKS_PORT | The SOCKS port. | 9150 |
| Variable name | Usage | Default |
| ---------------- | --------------------------------------------------------------- | ------------ |
| DATA_DIRECTORY | The data directory. | /var/lib/tor |
| LOG_LEVEL | The logging level. | notice |
| LOG_FILE | The log file or device. | stdout |
| SOCKS_HOSTNAME | The SOCKS hostname. | 127.0.0.0.1 |
| SOCKS_PORT | The SOCKS port. | 9150 |
| TORRC_APPEND | A block of configuration appended at the end of the torrc file. | |

Note that the defaults are the same as Tor's default if the
configuration option is not set.
Expand Down
5 changes: 3 additions & 2 deletions tor/tor-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,19 @@ else
# Escaping predefined variables names except
# SHELL_FORMAT_EXTRA, as we don't want them to be
# expanded.
SHELL_FORMAT="\${DATA_DIRECTORY},\${LOG_LEVEL},\${LOG_FILE},\${SOCKS_HOSTNAME},\${SOCKS_PORT},${SHELL_FORMAT_EXTRA}"
SHELL_FORMAT="\${DATA_DIRECTORY},\${LOG_LEVEL},\${LOG_FILE},\${SOCKS_HOSTNAME},\${SOCKS_PORT},\${TORRC_APPEND},${SHELL_FORMAT_EXTRA}"
else
# Using single quotes here on purpose, we don't want the
# variables names to be expanded.
# shellcheck disable=SC2016
SHELL_FORMAT='${DATA_DIRECTORY},${LOG_LEVEL},${LOG_FILE},${SOCKS_HOSTNAME},${SOCKS_PORT}'
SHELL_FORMAT='${DATA_DIRECTORY},${LOG_LEVEL},${LOG_FILE},${SOCKS_HOSTNAME},${SOCKS_PORT},${TORRC_APPEND}'
fi
DATA_DIRECTORY="${DATA_DIRECTORY:-/var/lib/tor}" \
LOG_LEVEL="${LOG_LEVEL:-notice}" \
LOG_FILE="${LOG_FILE:-stdout}" \
SOCKS_HOSTNAME="${SOCKS_HOSTNAME:-127.0.0.1}" \
SOCKS_PORT="${SOCKS_PORT:-9050}" \
TORRC_APPEND="${TORRC_APPEND:-}" \
envsubst "${SHELL_FORMAT}" </etc/tor/torrc.template >/etc/tor/torrc
fi

Expand Down
3 changes: 2 additions & 1 deletion tor/torrc.template
Original file line number Diff line number Diff line change
Expand Up @@ -248,5 +248,6 @@ DataDirectory ${DATA_DIRECTORY}
## folder will be parsed following lexical order. Files starting with a dot are ignored. Files
## on subfolders are ignored.
## The %include option can be used recursively.
#%include /etc/torrc.d/*.conf
%include /etc/torrc.d/*.conf

${TORRC_APPEND}

0 comments on commit 48fa1a8

Please sign in to comment.