From 980dcf01df1282c08f749bf7e1d6a0b7ecd6bb8f Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 2 Nov 2017 14:22:23 +0000 Subject: [PATCH] Create a tor onion service for mesh peers if they are connected via ethernet --- src/freedombone-image-mesh | 5 +++++ src/freedombone-mesh-batman | 24 ++++++++++++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/src/freedombone-image-mesh b/src/freedombone-image-mesh index 9ee67347..7b5cbd63 100755 --- a/src/freedombone-image-mesh +++ b/src/freedombone-image-mesh @@ -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 diff --git a/src/freedombone-mesh-batman b/src/freedombone-mesh-batman index aa2b8e12..5b28fc67 100755 --- a/src/freedombone-mesh-batman +++ b/src/freedombone-mesh-batman @@ -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 }