Experimental support for sending email via onion addresses

This commit is contained in:
Bob Mottram 2018-03-22 21:56:47 +00:00
parent ec1b8638e2
commit 660d73f726
1 changed files with 59 additions and 29 deletions

View File

@ -150,40 +150,70 @@ function configure_email_onion {
set_completion_param "email onion domain" "${onion_address}" set_completion_param "email onion domain" "${onion_address}"
add_email_hostname "$onion_address" add_email_hostname "$onion_address"
#echo "$DEFAULT_DOMAIN_NAME $onion_address" > /etc/exim4/onionrelay.txt apt-get -yq install tinycdb perl
#cdb -m -c -t /tmp/onionrelay.tmp /etc/exim4/onionrelay.cdb /etc/exim4/onionrelay.txt
#{ "perl_startup = do '/etc/exim4/perl-routines.pl'"; # MX record should be:
# "perl_at_start"; } > /etc/exim4/conf.d/main/perl # _onion-mx._tcp.$DEFAULT_DOMAIN_NAME. 3600 IN SRV 0 5 25 $onion_address
#{ "use Net::DNS::Resolver;"; echo "$DEFAULT_DOMAIN_NAME $onion_address" > /etc/exim4/onionrelay.txt
# "sub onionLookup {"; cdb -m -c -t ~/onionrelay.tmp /etc/exim4/onionrelay.cdb /etc/exim4/onionrelay.txt
# " my \$hostname = shift;";
# " my \$res = Net::DNS::Resolver->new(nameservers => [qw(127.0.0.1)],);";
# " \$res->port(5300);";
# " my \$query = \$res->search(\$hostname);";
# " foreach my \$rr (\$query->answer) {";
# " next unless \$rr->type eq \"A\";";
# " return \$rr->address;";
# " }";
# " return 'no_such_host';";
# "}"; } > /etc/exim4/perl-routines.pl
#{ "ONION_RELAYDB=/etc/exim4/onionrelay.cdb"; { "perl_startup = do '/etc/exim4/perl-routines.pl'";
# "domainlist onion_relays = cdb;ONION_RELAYDB"; } > /etc/exim4/conf.d/domainlists "perl_at_start"; } > /etc/exim4/conf.d/main/perl
#{ "# send things over tor where we have an entry for it"; { "use Net::DNS::Resolver;";
# "onionrelays:"; "sub onionLookup {";
# " driver = manualroute"; " my \$hostname = shift;";
# " domains = +onion_relays"; " my \$res = Net::DNS::Resolver->new(nameservers => [qw(127.0.0.1)],);";
# " transport = onion_relay"; " \$res->port(5300);";
# " # get the automap IP for the onion address from the tor daemon"; " my \$query = \$res->search(\$hostname);";
# " route_data = \${perl{onionLookup}{\${lookup{\$domain}cdb{ONION_RELAYDB}}}}"; " foreach my \$rr (\$query->answer) {";
# " no_more"; } > /etc/exim4/conf.d/router/50_exim4-config-onion " next unless \$rr->type eq \"A\";";
" return \$rr->address;";
" }";
" return 'no_such_host';";
"}"; } > /etc/exim4/perl-routines.pl
#{ "onion_relay:"; { "ONION_RELAYDB=/etc/exim4/onionrelay.cdb";
# " driver = smtp"; "domainlist onion_relays = cdb;ONION_RELAYDB"; } > /etc/exim4/conf.d/domainlists
# " socks_proxy = 127.0.0.1 port=9050"; } > /etc/exim4/conf.d/transport/50_exim4-config_onion
{ "# send things over tor where we have an entry for it";
"onionrelays:";
" driver = manualroute";
" domains = +onion_relays";
" transport = onion_relay";
" # get the automap IP for the onion address from the tor daemon";
" route_data = \${perl{onionLookup}{\${lookup{\$domain}cdb{ONION_RELAYDB}}}}";
" no_more"; } > /etc/exim4/conf.d/router/50_exim4-config-onion
{ "onion_relay:";
" driver = smtp";
" socks_proxy = 127.0.0.1 port=9050"; } > /etc/exim4/conf.d/transport/50_exim4-config_onion
if ! grep -q "AutomapHostsOnResolve" /etc/tor/torrc; then
echo 'AutomapHostsOnResolve 1' >> /etc/tor/torrc
else
sed -i 's|#AutomapHostsOnResolve.*|AutomapHostsOnResolve 1|g' /etc/tor/torrc
sed -i 's|AutomapHostsOnResolve.*|AutomapHostsOnResolve 1|g' /etc/tor/torrc
fi
if ! grep -q "DNSPort " /etc/tor/torrc; then
echo 'DNSPort 5300' >> /etc/tor/torrc
else
sed -i 's|#DNSPort .*|DNSPort 5300|g' /etc/tor/torrc
sed -i 's|DNSPort .*|DNSPort 5300|g' /etc/tor/torrc
fi
if ! grep -q "DNSListenAddress" /etc/tor/torrc; then
echo 'DNSListenAddress 127.0.0.1' >> /etc/tor/torrc
else
sed -i 's|#DNSListenAddress.*|DNSListenAddress 127.0.0.1|g' /etc/tor/torrc
sed -i 's|DNSListenAddress.*|DNSListenAddress 127.0.0.1|g' /etc/tor/torrc
fi
dpkg-reconfigure --frontend noninteractive exim4-config
systemctl restart tor
systemctl restart exim4
mark_completed "${FUNCNAME[0]}" mark_completed "${FUNCNAME[0]}"
} }