Bladeren bron

Tidied up the tinyproxy integration and added env vars and documentation

master
Jeremy Andrews 7 jaren geleden
bovenliggende
commit
af699006c7
7 gewijzigde bestanden met toevoegingen van 33 en 127 verwijderingen
  1. 3
    1
      DockerEnv
  2. 12
    0
      README.md
  3. 3
    1
      docker-compose-armhf.yml
  4. 3
    1
      docker-compose.yml
  5. 10
    2
      openvpn/start.sh
  6. 0
    121
      tinyproxy/run.sh
  7. 2
    1
      tinyproxy/setport.sh

+ 3
- 1
DockerEnv Bestand weergeven

@@ -75,4 +75,6 @@
#TRANSMISSION_UTP_ENABLED=true
#TRANSMISSION_WATCH_DIR=/data/watch
#TRANSMISSION_WATCH_DIR_ENABLED=true
#TRANSMISSION_HOME=/data/transmission-home
#TRANSMISSION_HOME=/data/transmission-home
#WEBPROXY_ENABLED=true
#WEBPROXY_PORT=8888

+ 12
- 0
README.md Bestand weergeven

@@ -97,6 +97,18 @@ As you can see the variables are prefixed with `TRANSMISSION_`, the variable is
PS: `TRANSMISSION_BIND_ADDRESS_IPV4` will be overridden to the IP assigned to your OpenVPN tunnel interface.
This is to prevent leaking the host IP.

### Web proxy configuration options

This container also contains a web-proxy server to allow you to tunnel your web-browser traffic through the same OpenVPN tunnel.
This is useful if you are using a private tracker that needs to see you login from the same IP address you are torrenting from.
The default listening port is 8888. Note that only ports above 1024 can be specified as all ports below 1024 are privileged
and would otherwise require root permissions to run.

| Variable | Function | Example |
|----------|----------|-------|
|`WEBPROXY_ENABLED` | Enables the web proxy | `WEBPROXY_ENABLED=true`|
|`WEBPROXY_PORT` | Sets the listening port | `WEBPROXY_PORT=8888` |

### User configuration options

By default everything will run as the root user. However, it is possible to change who runs the transmission process.

+ 3
- 1
docker-compose-armhf.yml Bestand weergeven

@@ -10,6 +10,7 @@ services:
restart: always
ports:
- "9091:9091"
- "8888:8888"
dns:
- 8.8.8.8
- 8.8.4.4
@@ -22,7 +23,8 @@ services:
- OPENVPN_PASSWORD=password
- OPENVPN_OPTS=--inactive 3600 --ping 10 --ping-exit 60
- LOCAL_NETWORK=192.168.0.0/24

- WEBPROXY_ENABLED=true
- WEBPROXY_PORT=8888
proxy:
build:
context: ./proxy

+ 3
- 1
docker-compose.yml Bestand weergeven

@@ -6,6 +6,7 @@ services:
restart: always
ports:
- "9091:9091"
- "8888:8888"
dns:
- 8.8.8.8
- 8.8.4.4
@@ -18,7 +19,8 @@ services:
- OPENVPN_PASSWORD=password
- OPENVPN_OPTS="--inactive 3600 --ping 10 --ping-exit 60"
- LOCAL_NETWORK=192.168.0.0/24

- WEBPROXY_ENABLED=true
- WEBPROXY_PORT=8888
proxy:
image: haugene/transmission-openvpn-proxy
links:

+ 10
- 2
openvpn/start.sh Bestand weergeven

@@ -54,7 +54,15 @@ if [ -n "${LOCAL_NETWORK-}" ]; then
fi
fi

/opt/tinyproxy/run.sh ANY
/etc/init.d/tinyproxy start

if [ "${WEBPROXY_ENABLED}" = "true" ]; then
if [ -z "$WEBPROXY_PORT" ] ; then
/opt/tinyproxy/setport.sh $WEBPROXY_PORT
else
# Alway default back to port 8888
/opt/tinyproxy/setport.sh 8888
fi
/etc/init.d/tinyproxy start
fi

exec openvpn $TRANSMISSION_CONTROL_OPTS $OPENVPN_OPTS --config "$OPENVPN_CONFIG"

+ 0
- 121
tinyproxy/run.sh Bestand weergeven

@@ -1,121 +0,0 @@
#!/bin/bash

# Global vars
PROG_NAME='DockerTinyproxy'
PROXY_CONF='/etc/tinyproxy.conf'
TAIL_LOG='/var/log/tinyproxy/tinyproxy.log'

# Usage: screenOut STATUS message
screenOut() {
timestamp=$(date +"%H:%M:%S")
if [ "$#" -ne 2 ]; then
status='INFO'
message="$1"
else
status="$1"
message="$2"
fi

echo -e "[$PROG_NAME][$status][$timestamp]: $message"
}

# Usage: checkStatus $? "Error message" "Success message"
checkStatus() {
case $1 in
0)
screenOut "SUCCESS" "$3"
;;
1)
screenOut "ERROR" "$2 - Exiting..."
exit 1
;;
*)
screenOut "ERROR" "Unrecognised return code."
;;
esac
}

stopService() {
screenOut "Checking for running Tinyproxy service..."
if [ "$(pidof tinyproxy)" ]; then
screenOut "Found. Stopping Tinyproxy service for pre-configuration..."
killall tinyproxy
checkStatus $? "Could not stop Tinyproxy service." \
"Tinyproxy service stopped successfully."
else
screenOut "Tinyproxy service not running."
fi
}

parseAccessRules() {
list=''
for ARG in $@; do
line="Allow\t$ARG\n"
list+=$line
done
echo "$list" | sed 's/.\{2\}$//'
}

setMiscConfig() {
sed -i -e"s,^MinSpareServers ,MinSpareServers\t1 ," $PROXY_CONF
checkStatus $? "Set MinSpareServers - Could not edit $PROXY_CONF" \
"Set MinSpareServers - Edited $PROXY_CONF successfully."

sed -i -e"s,^MaxSpareServers ,MaxSpareServers\t1 ," $PROXY_CONF
checkStatus $? "Set MinSpareServers - Could not edit $PROXY_CONF" \
"Set MinSpareServers - Edited $PROXY_CONF successfully."
sed -i -e"s,^StartServers ,StartServers\t1 ," $PROXY_CONF
checkStatus $? "Set MinSpareServers - Could not edit $PROXY_CONF" \
"Set MinSpareServers - Edited $PROXY_CONF successfully."
}

enableLogFile() {
touch /var/log/tinyproxy/tinyproxy.log
sed -i -e"s,^#LogFile,LogFile," $PROXY_CONF
}

setAccess() {
if [[ "$1" == *ANY* ]]; then
sed -i -e"s/^Allow /#Allow /" $PROXY_CONF
checkStatus $? "Allowing ANY - Could not edit $PROXY_CONF" \
"Allowed ANY - Edited $PROXY_CONF successfully."
else
sed -i "s,^Allow 127.0.0.1,$1," $PROXY_CONF
checkStatus $? "Allowing IPs - Could not edit $PROXY_CONF" \
"Allowed IPs - Edited $PROXY_CONF successfully."
fi
}

startService() {
screenOut "Starting Tinyproxy service..."
/usr/sbin/tinyproxy
checkStatus $? "Could not start Tinyproxy service." \
"Tinyproxy service started successfully."
}

tailLog() {
screenOut "Tailing Tinyproxy log..."
tail -f $TAIL_LOG
checkStatus $? "Could not tail $TAIL_LOG" \
"Stopped tailing $TAIL_LOG"
}

# Start script
echo && screenOut "$PROG_NAME script started..."
# Stop Tinyproxy if running
stopService
# Parse ACL from args
export rawRules="$@" && parsedRules=$(parseAccessRules $rawRules) && unset rawRules
# Set ACL in Tinyproxy config
setAccess $parsedRules
# Enable log to file
#enableLogFile
# Start Tinyproxy
startService
# Tail Tinyproxy log
#tailLog
# End
screenOut "$PROG_NAME script ended." && echo
exit 0

+ 2
- 1
tinyproxy/setport.sh Bestand weergeven

@@ -13,10 +13,11 @@ fi

if [ $1 \< 1024 ];
then
echo "$1 is lower than 1024. Ports below 1024 are not permitted.";
echo "tinyproxy: $1 is lower than 1024. Ports below 1024 are not permitted.";
exit 1
fi;

echo "Setting tinyproxy port to $1";
sed -i -e"s,^Port .*,Port $1," $PROXY_CONF

exit 0

Laden…
Annuleren
Opslaan