Browse Source

back to TOR v3

#146
rootzoll 7 years ago
parent
commit
d85e63c5c5
  1. 94
      home.admin/96addTorService.sh
  2. 7
      home.admin/assets/getpublicip.sh
  3. 2
      home.admin/assets/lnd.tor.service

94
home.admin/96addTorService.sh

@ -121,14 +121,6 @@ sudo systemctl daemon-reload
sudo systemctl restart tor@default
echo ""
echo "*** Setting Permissions ***"
# so that chain network can create Tor hidden service
#echo "setting bitcoind permissions"
#sudo usermod -a -G debian-tor bitcoin
# so that you can run `arm` as user
#echo "setting pi permissions"
#sudo usermod -a -G debian-tor pi
echo "*** Waiting for TOR to boostrap ***"
torIsBootstrapped=0
while [ ${torIsBootstrapped} -eq 0 ]
@ -144,66 +136,72 @@ done
echo "OK - Tor Bootstrap is ready"
echo ""
if [ "${network}" = "bitcoin" ]; then
echo "*** Changing ${network} Config ***"
networkIsTor=$(sudo cat /home/bitcoin/.${network}/${network}.conf | grep 'onlynet=onion' -c)
if [ ${networkIsTor} -eq 0 ]; then
echo "Only Connect thru TOR"
echo "onlynet=onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "*** Changing ${network} Config ***"
networkIsTor=$(sudo cat /home/bitcoin/.${network}/${network}.conf | grep 'onlynet=onion' -c)
if [ ${networkIsTor} -eq 0 ]; then
echo "Only Connect thru TOR"
echo "onlynet=onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "Adding some nodes to connect to"
if [ "${network}" = "bitcoin" ]; then
echo "Adding some bitcoin onion nodes to connect to"
echo "addnode=fno4aakpl6sg6y47.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=toguvy5upyuctudx.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=ndndword5lpb7eex.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=6m2iqgnqjxh7ulyk.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
echo "addnode=5tuxetn7tar3q5kp.onion" | sudo tee --append /home/bitcoin/.${network}/${network}.conf
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
else
echo "Chain network already configured for TOR"
fi
echo "*** ${network} re-init - Waiting for Onion Address ***"
# restarting bitcoind to start with tor and generare onion.address
echo "restarting ${network}d ..."
sudo systemctl restart ${network}d
sleep 8
onionAddress=""
while [ ${#onionAddress} -eq 0 ]
do
echo "--- Checking ---"
date +%s
testNetAdd=""
if [ "${chain}" = "test" ];then
testNetAdd="/testnet3"
fi
sudo cat /mnt/hdd/${network}${testNetAdd}/debug.log 2>/dev/null | grep "tor" | tail -n 10
onionAddress=$(${network}-cli getnetworkinfo | grep '"address"' | cut -d '"' -f4)
echo "If this takes too long --> CTRL+c, reboot and check manually"
sleep 5
done
onionPort=$(${network}-cli getnetworkinfo | grep '"port"' | tr -dc '0-9')
echo "Your Chain Network Onion Address is: ${onionAddress}:${onionPort}"
echo ""
sudo cp /home/bitcoin/.${network}/${network}.conf /home/admin/.${network}/${network}.conf
sudo chown admin:admin /home/admin/.${network}/${network}.conf
else
echo "Dont run '${network}' behind tor"
fi
echo "Chain network already configured for TOR"
fi
echo "*** ${network} re-init - Waiting for Onion Address ***"
# restarting bitcoind to start with tor and generare onion.address
echo "restarting ${network}d ..."
sudo systemctl restart ${network}d
sleep 8
onionAddress=""
while [ ${#onionAddress} -eq 0 ]
do
echo "--- Checking ---"
date +%s
testNetAdd=""
if [ "${chain}" = "test" ];then
testNetAdd="/testnet3"
fi
sudo cat /mnt/hdd/${network}${testNetAdd}/debug.log 2>/dev/null | grep "tor" | tail -n 10
onionAddress=$(${network}-cli getnetworkinfo | grep '"address"' | cut -d '"' -f4)
echo "If this takes too long --> CTRL+c, reboot and check manually"
sleep 5
done
onionPort=$(${network}-cli getnetworkinfo | grep '"port"' | tr -dc '0-9')
echo "Your Chain Network Onion Address is: ${onionAddress}:${onionPort}"
echo ""
#echo "*** Setting your Onion Address ***"
#onionLND=$(sudo cat /mnt/hdd/tor/lnd9735/hostname)
#echo "Your Lightning Tor Onion Address is: ${onionLND}:9735"
#echo ""
echo "*** Setting your Onion Address ***"
onionLND=$(sudo cat /mnt/hdd/tor/lnd9735/hostname)
echo "Your Lightning Tor Onion Address is: ${onionLND}:9735"
echo ""
# ACTIVATE LND OVER TOR
echo "*** Putting LND behind TOR ***"
echo "Disable LND again"
sudo systemctl disable lnd
echo "Writing Public Onion Address to /run/publicip"
echo "PUBLICIP=${onionLND}" | sudo tee /run/publicip
echo "Configure and Changing to lnd.tor.service"
sed -i "5s/.*/Wants=${network}d.service/" ./assets/lnd.tor.service
sed -i "6s/.*/After=${network}d.service/" ./assets/lnd.tor.service
sudo cp /home/admin/assets/lnd.tor.service /etc/systemd/system/lnd.service
sudo chmod +x /etc/systemd/system/lnd.service
echo "Enable LND again"
sudo systemctl enable lnd
echo "OK"
echo ""
echo "*** Finshing Setup / REBOOT ***"
echo "OK - all should be set"

7
home.admin/assets/getpublicip.sh

@ -5,12 +5,9 @@
echo 'getpublicip.sh started, writing public IP address every 10 minutes into /run/publicip'
while [ 0 ];
do
# when TOR is installed the fixed onion address is already in /run/publicip
torExists=$(sudo ls /mnt/hdd/tor/web80/hostname 2>/dev/null | grep hostname -c)
if [ ${torExists} -eq 1 ]; then
# use tor onion address
# printf "PUBLICIP=$(sudo cat /mnt/hdd/tor/lnd9735/hostname)\n" > /run/publicip;
# just leave /run/publicip
else
if [ ${torExists} -eq 0 ]; then
# get public IP
printf "PUBLICIP=$(curl -vv ipinfo.io/ip 2> /run/publicip.log)\n" > /run/publicip;
fi

2
home.admin/assets/lnd.tor.service

@ -13,7 +13,7 @@ After=bitcoind.service
EnvironmentFile=/run/publicip
# TOR Hidden Service v2
# had bad memory performance with raspi with lnd 0.4.2
# bad memory performance with raspi with lnd 0.4.2
# ExecStart=/usr/local/bin/lnd --tor.active --tor.v2 --listen=127.0.0.1:9735
# --tor.V2PrivateKeyPath=/mnt/hdd/bitcoin/[testnet3/]onion_private_key

Loading…
Cancel
Save