-
Notifications
You must be signed in to change notification settings - Fork 14
/
torrc.tmpl
42 lines (35 loc) · 1.3 KB
/
torrc.tmpl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
User tor
DataDirectory /var/lib/tor
SocksPort 0
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
{{ range $name, $containers := groupByMulti $ "Env.ONIONSERVICE_NAME" "," }}
# {{ $name }}
HiddenServiceDir /var/lib/tor/onion_services/{{ $name }}
HiddenServiceVersion 3
{{ range $index, $container := $containers }}
{{ $addrLen := len $container.Addresses }}
{{/* If only 1 port exposed, use that */}}
{{ if eq $addrLen 1 }}
{{ with $address := index $container.Addresses 0 }}
# auto: single port exposed
HiddenServicePort {{ $address.Port }} {{ $container.Name }}:{{ $address.Port }}
{{ end }}
{{/* If more than one port exposed, use the one matching ONIONSERVICE_PORT env var */}}
{{ else if $container.Env.ONIONSERVICE_PORT }}
{{ range $i, $address := $container.Addresses }}
{{ if eq $address.Port $container.Env.ONIONSERVICE_PORT }}
# port specified by ONIONSERVICE_PORT
HiddenServicePort {{ $address.Port }} {{ $container.Name }}:{{ $address.Port }}
{{ end }}
{{ end }}
{{/* Else default to standard web port 80 */}}
{{ else }}
{{ range $i, $address := $container.Addresses }}
{{ if eq $address.Port "80" }}
# auto: standard port 80
HiddenServicePort {{ $address.Port }} {{ $container.Name }}:{{ $address.Port }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}