-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtorrc.tmpl
30 lines (28 loc) · 1.35 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
{{ $CurrentContainer := where $ "ID" .Docker.CurrentContainerID | first }}
{{ range $name, $containers := groupByMulti $ "Env.HIDDENSERVICE_NAME" "," }}
{{ $firstServicePort := true }}
{{ range $container := $containers }}
{{ range $knownNetwork := $CurrentContainer.Networks }}
{{ range $containerNetwork := $container.Networks }}
{{ if eq $knownNetwork.Name $containerNetwork.Name }}
{{ $containerOrReverseProxyName := coalesce $container.Env.HIDDENSERVICE_REVERSEPROXY $container.Name }}
{{ range $reverseProxyContainer := where $ "Name" $containerOrReverseProxyName }}
{{ range $containerNetwork := where $reverseProxyContainer.Networks "Name" $knownNetwork.Name }}
{{ $port := coalesce $container.Env.HIDDENSERVICE_PORT "80" }}
{{ $virtualPort := coalesce $container.Env.HIDDENSERVICE_VIRTUAL_PORT $port }}
{{ if ne $containerNetwork.IP "" }}
{{ if $firstServicePort }}
# For the hidden service {{ $name }}
HiddenServiceDir /var/lib/tor/hidden_services/{{ $name }}
{{ $firstServicePort := false }}
{{ end }}
# Redirecting to {{ $containerOrReverseProxyName }}
HiddenServicePort {{ $virtualPort }} {{ $containerNetwork.IP }}:{{ $port }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}
{{ end }}