Create a tor onion service for mesh peers if they are connected via ethernet

This commit is contained in:
Bob Mottram 2017-11-02 14:22:23 +00:00
parent 7e23ab7b87
commit 980dcf01df
2 changed files with 29 additions and 0 deletions

View File

@ -990,6 +990,11 @@ if [ -f $MESH_INSTALL_SETUP ]; then
rm -rf /etc/openvpn/easy-rsa/keys/*
fi
# Remove hidden service
if [ -d /var/lib/tor/hidden_service_mesh ]; then
rm -rf /var/lib/tor/hidden_service_mesh
fi
# Remove any existing vpn client keys
if [ -f /home/$MY_USERNAME/vpn.tar.gz ]; then
rm /home/$MY_USERNAME/vpn.tar.gz

View File

@ -416,6 +416,30 @@ function start {
fi
fi
# if we have an ethernet connection to an internet router then create
# an onion address for this peer
if [[ "$ethernet_connected" != "0" ]]; then
systemctl enable tor
systemctl start tor
HIDDEN_SERVICE_PATH=/var/lib/tor/hidden_service_
if [ ! -f ${HIDDEN_SERVICE_PATH}mesh/hostname ]; then
echo "HiddenServiceDir ${HIDDEN_SERVICE_PATH}mesh/" >> /etc/tor/torrc
echo "HiddenServicePort 8008 127.0.0.1:8008" >> /etc/tor/torrc
echo "HiddenServicePort 8010 127.0.0.1:8010" >> /etc/tor/torrc
echo "HiddenServicePort ${TOX_PORT} 127.0.0.1:${TOX_PORT}" >> /etc/tor/torrc
echo "HiddenServicePort ${IPFS_PORT} 127.0.0.1:${IPFS_PORT}" >> /etc/tor/torrc
echo "HiddenServicePort ${ZERONET_PORT} 127.0.0.1:${ZERONET_PORT}" >> /etc/tor/torrc
echo "HiddenServicePort 5353 127.0.0.1:5353" >> /etc/tor/torrc
echo "HiddenServicePort 5354 127.0.0.1:5354" >> /etc/tor/torrc
echo "HiddenServicePort 548 127.0.0.1:548" >> /etc/tor/torrc
echo "HiddenServiceAuthorizeClient stealth mesh" >> /etc/tor/torrc
systemctl restart tor
fi
else
systemctl stop tor
systemctl disable tor
fi
verify
}