Skip to content

Commit f47dbf3

Browse files
committed
torrc-related server scripts
1 parent d0a332f commit f47dbf3

File tree

3 files changed

+78
-11
lines changed

3 files changed

+78
-11
lines changed

README.txt

+10-11
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ Alliuminated domain.webm
2525
its README for more information. SAT domains used to be called "Alliuminated"
2626
domains.
2727

28-
nginx.conf.tmpl
28+
server-scripts/
2929

30-
The starting point for an nginx config file. When parsed, it configures nginx
31-
to add the necessary HTTP headers to its responses for our extension to work.
30+
Scripts and config templates useful for the managing the server-side. This
31+
includes an nginx config template and update script, as well as a torrc
32+
config template and update script.
3233

3334
tor/
3435

@@ -41,10 +42,6 @@ tor.selfauth-sig-0.3.5.7.tar.xz
4142
The Tor code as of my branch selfauth-sig-0.3.5.7 in case this is easier for
4243
you than a submodule.
4344

44-
update-satis-sig-nginx-conf.sh
45-
46-
Take the signatures generated by Tor, combine them with the nginx config
47-
template, and outputs the final nginx template.
4845

4946
Setting Up Client Side (Easy mode)
5047
----------------------------------
@@ -145,10 +142,12 @@ work.
145142
Tor has generated its signature over the appropriate data in
146143
data/hs/satis_sig.
147144

148-
I use nginx and (at the time of writing) the included nginx.conf.tmpl and
149-
update-satis-sig-nginx-conf.sh to get this data into my nginx config. These
150-
are a little more complex than would be necessary for other people,
151-
especially if you don't want to use the purposefully bad signatures too.
145+
I use nginx and (at the time of writing) the included
146+
server-scripts/nginx.conf.tmpl and
147+
server-scripts/update-satis-sig-nginx-conf.sh to get this data into my nginx
148+
config. These are a little more complex than would be necessary for other
149+
people, especially if you don't want to use the purposefully bad signatures
150+
too.
152151

153152
To encoded the file in base 64, do something like this:
154153

server-scripts/torrc.tmpl

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This is a torrc fragment that can be %include-d in a fuller torrc.
2+
# For example:
3+
# SocksPort 0
4+
# DataDirectory data
5+
# Log notice file data/notice.log
6+
# PidFile data/tor.pid
7+
# # ... more torrc options you may have ...
8+
# %include foo.com.torrc
9+
# %include bar.com.torrc
10+
# # ... more torrc options you may have ...
11+
HiddenServiceDir data/hs
12+
HiddenServicePort 443
13+
HiddenServiceVersion 3
14+
HiddenServiceSatisSig 1
15+
HiddenServiceSatisDomain M4_TRAD_DOMAIN
16+
HiddenServiceSatisFingerprint M4_TLS_FP
17+
HiddenServiceSatisSigInterval 86400

server-scripts/update-torrc.sh

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env bash
2+
set -e
3+
4+
# Variables
5+
####################################
6+
cert_fname="/etc/letsencrypt/live/satis.system33.pw/fullchain.pem"
7+
traditional_domain_name="satis.system33.pw"
8+
torrc_tmpl_fname="torrc.tmpl"
9+
torrc_out_fname="/home/satis/src/tor/satis.system33.pw.torrc"
10+
reload_tor_command="cat /home/satis/src/tor/data/tor.pid | xargs kill -HUP"
11+
12+
# Useful functions
13+
####################################
14+
function fail {
15+
echo $1 >&2
16+
exit 1
17+
}
18+
19+
function get_cert_fp {
20+
# Use openssl to get the given certificate's SHA256 fingerprint
21+
fname="$1"
22+
[ "$fname" != "" ] || fail "Must pass a filename to get_cert_fp"
23+
[ -f "$fname" ] || fail "$fname does not exist"
24+
openssl x509 -in "$fname" -noout -fingerprint -sha256 |\
25+
cut -d '=' -f 2 | tr -d ':'
26+
}
27+
28+
# Check that we are root, because we probably need to be
29+
####################################
30+
[ "$EUID" == "0" ] || fail "$0 should be run as root"
31+
32+
# Check that needed programs exist
33+
####################################
34+
which openssl &>/dev/null || fail "Missing required program openssl"
35+
which m4 &>/dev/null || fail "Missing required program m4"
36+
which cut &>/dev/null || fail "Missing required program cut"
37+
which tr &>/dev/null || fail "Missing required program tr"
38+
39+
# Check that needed files exist
40+
####################################
41+
[ -f "$cert_fname" ] || fail "$cert_fname must exist"
42+
43+
# Begin program
44+
####################################
45+
fp="$(get_cert_fp "$cert_fname")"
46+
m4 \
47+
-DM4_TRAD_DOMAIN="$traditional_domain_name"\
48+
-DM4_TLS_FP="$fp" \
49+
"$torrc_tmpl_fname" > "$torrc_out_fname"
50+
51+
eval "$reload_tor_command"

0 commit comments

Comments
 (0)