Skip to content

Commit

Permalink
add option to switch between legacy/DCO ciphers
Browse files Browse the repository at this point in the history
  • Loading branch information
flameshikari authored and xtrime-ru committed Aug 19, 2024
1 parent 5b204d6 commit d831144
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ services:
environment:
- DOMAIN
- PORT
- CBC_CIPHERS
- DNS
- DNS_RU
ports:
Expand Down
23 changes: 20 additions & 3 deletions rootfs/init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# run commands after systemd initialization

function postrun () {
waiter="until ps -p 1 | grep -q systemd; do sleep 0.1; done; sleep 1"
local waiter="until ps -p 1 | grep -q systemd; do sleep 0.1; done; sleep 1"
nohup bash -c "$waiter; $@" &
}

Expand All @@ -14,21 +14,33 @@ function postrun () {
function resolve () {
# $1 domain/ip address, $2 fallback domain/ip address
ipcalc () { ipcalc-ng --no-decorate -o $1 2> /dev/null; }
ipaddr=$(ipcalc $1 || ipcalc $2)
local ipaddr=$(ipcalc $1 || ipcalc $2)
echo ${ipaddr:-127.0.0.11} # fallback to docker internal dns
}


# set ciphers

function set_ciphers () {
# $1 AES-128-CBC:AES-256-CBC[:...]
local CIPHERS=AES-128-GCM:AES-256-GCM
local ARGS=$([ -n "$1" ] && echo "$CIPHERS:$1" || echo "$CIPHERS")
sed -i "s|data-ciphers .*|data-ciphers \"$ARGS\"|g" /etc/openvpn/server/*.conf
}


# save DNS variables to /etc/default/antizapret
# in order to systemd services can access them

cat << EOF | tee /etc/default/antizapret
CBC_CIPHERS=${CBC_CIPHERS:-0}
DNS=$(resolve $DNS)
DNS_RU=$(resolve $DNS_RU 77.88.8.8)
PYTHONUNBUFFERED=1
EOF


# autoload vars when logging in into shell with 'bash -l'
# autoload vars when logging in into shell with 'bash -l'
ln -sf /etc/default/antizapret /etc/profile.d/antizapret.sh


Expand All @@ -45,6 +57,11 @@ done
/root/openvpn/generate.sh


# swap between legacy ciphers and DCO-required ciphers

[[ "$CBC_CIPHERS" == 1 ]] && set_ciphers AES-128-CBC:AES-256-CBC || set_ciphers


# output systemd logs to docker logs
postrun journalctl -f --no-hostname --since "$(date '+%Y-%m-%d %T')"

Expand Down

0 comments on commit d831144

Please sign in to comment.