Skip to content

Commit 3aeb802

Browse files
committed
add script to generate ech files and support running a hourly user cron script
Signed-off-by: Zoey <zoey@z0ey.de>
1 parent a9d38fb commit 3aeb802

3 files changed

Lines changed: 54 additions & 3 deletions

File tree

rootfs/usr/local/bin/ech.sh

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
#!/usr/bin/env sh
2+
3+
set -e
4+
umask 077
5+
6+
if [ "$#" -lt 2 ] || [ "$#" -gt 3 ]; then
7+
echo "Usage: $0 <public-name> <filename> [max-name-length (default 64)]" >&2
8+
exit 1
9+
fi
10+
11+
if [ -s "/data/tls/ech/${2%.ech}-current.ech" ]; then mv "/data/tls/ech/${2%.ech}-current.ech" "/data/tls/ech/${2%.ech}-previous.ech"; fi
12+
13+
ECHPK=/tmp/private-key-${2%.ech}.bin
14+
ECHCL=/tmp/config-list-${2%.ech}.bin
15+
16+
bssl generate-ech \
17+
-public-name "$1" \
18+
-max-name-length "${3:-64}" \
19+
-config-id "$(hexdump -n 1 -e '"%u"' /dev/urandom)" \
20+
-out-ech-config /dev/null \
21+
-out-ech-config-list "$ECHCL" \
22+
-out-private-key "$ECHPK"
23+
24+
{
25+
echo "-----BEGIN PRIVATE KEY-----"
26+
( printf '\060\056\002\001\000\060\005\006\003\053\145\156\004\042\004\040'; cat "$ECHPK" ) | openssl base64
27+
echo "-----END PRIVATE KEY-----"
28+
echo "-----BEGIN ECHCONFIG-----"
29+
openssl base64 -in "$ECHCL"
30+
echo "-----END ECHCONFIG-----"
31+
} > "/data/tls/ech/${2%.ech}-current.ech"
32+
33+
openssl base64 -A -in "$ECHCL"
34+
echo
35+
36+
rm "$ECHPK" "$ECHCL"

rootfs/usr/local/bin/launch.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,5 +84,17 @@ if [ "$GOA" = "true" ]; then set -f; while true; do if [ -s /data/nginx/logs/acc
8484
--date-format="%d/%b/%Y" --log-format='[%d:%t %^] %v %h %T "%r" %s %b %b %R %u' --unix-socket=/run/goaccess.sock --log-file=/data/nginx/logs/access.log \
8585
--real-time-html --output=/tmp/goa/index.html --db-path=/data/goaccess/data --restore --persist \
8686
--browsers-file=/etc/goaccess/browsers.list --browsers-file=/etc/goaccess/podcast.list $GOACLA; else sleep 10s; fi; done; fi &
87+
while true; do
88+
if [ -s "/data/tls/ech/cron.sh" ]; then
89+
chmod +x /data/tls/ech/cron.sh
90+
/data/tls/ech/cron.sh
91+
sed -i "s|#ssl_ech_file|ssl_ech_file|g" /usr/local/nginx/conf/nginx.conf
92+
nginx -s reload
93+
elif grep -q '^[^#]*ssl_ech_file' /usr/local/nginx/conf/nginx.conf; then
94+
sed -i "s|ssl_ech_file|#ssl_ech_file|g" /usr/local/nginx/conf/nginx.conf
95+
nginx -s reload
96+
fi
97+
sleep 1h
98+
done &
8799
while true; do nginx -e stderr; done &
88100
while true; do index.js; done

rootfs/usr/local/bin/start.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ mkdir -vp /data/npmplus/gravatar \
114114
/data/tls/certbot/renewal \
115115
/data/tls/certbot/acme-challenge \
116116
/data/tls/custom \
117+
/data/tls/ech \
117118
/data/html \
118119
/data/access \
119120
/data/anubis \
@@ -229,7 +230,8 @@ rm -vrf /data/letsencrypt-acme-challenge \
229230
/data/nginx/temp \
230231
/data/logs
231232

232-
touch /data/html/index.html \
233+
touch /data/tls/ech/cron.sh \
234+
/data/html/index.html \
233235
/data/anubis/happy.webp \
234236
/data/anubis/reject.webp \
235237
/data/anubis/pensive.webp \
@@ -463,8 +465,9 @@ fi
463465
find /data/tls \
464466
/data/access \
465467
/data/npmplus \
466-
-not -perm 770 \
467-
-exec chmod 770 {} \;
468+
/data/nginx/logs \
469+
-not -perm 600 \
470+
-exec chmod 600 {} \;
468471

469472
rm -vf /usr/local/nginx/logs/nginx.pid
470473
rm -vf /run/*.sock

0 commit comments

Comments
 (0)