namecoin.patch 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. diff -ru RelativeLink/start-tor-browser RelativeLinkNamecoin/start-tor-browser
  2. --- RelativeLink/start-tor-browser 2019-11-03 06:56:36.000000000 +0000
  3. +++ RelativeLinkNamecoin/start-tor-browser 2019-11-20 17:06:09.321000000 +0000
  4. @@ -169,6 +169,11 @@
  5. detach=0
  6. fi
  7. +# We can't detach and enable Namecoin at the same time..
  8. +if [ "$TOR_ENABLE_NAMECOIN" = 1 -a "$detach" -eq 1 ]; then
  9. + detach=0
  10. +fi
  11. +
  12. if [ "$show_output" -eq 0 ]; then
  13. # If the user hasn't requested 'debug mode' or --help, close stdout and stderr,
  14. # to keep Firefox and the stuff loaded by/for it (including the
  15. @@ -352,6 +357,47 @@
  16. #
  17. # The --class parameter was added to fix bug 11102.
  18. +# The Namecoin support in this script is a placeholder proof-of-concept only.
  19. +# In the real world this would be moved to Tor Launcher.
  20. +if [ "${TOR_ENABLE_NAMECOIN}" = 1 ]; then
  21. + python3 -c 'import sys; exit(0) if sys.version_info[:2] >= (3, 6) else exit(1)'
  22. + if [ "$?" -ne 0 ]; then
  23. + complain "Namecoin requires at least Python 3.6."
  24. + exit 1
  25. + fi
  26. +
  27. + if [ "$show_usage" -eq 1 ]; then
  28. + # No help exists for Namecoin
  29. + TOR_ENABLE_NAMECOIN=0
  30. + elif [ "$detach" -eq 1 ] ; then
  31. + # No support yet for detached Namecoin
  32. + TOR_ENABLE_NAMECOIN=0
  33. + elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
  34. + # No support yet for logging Namecoin
  35. + TOR_ENABLE_NAMECOIN=0
  36. + elif [ "$show_output" -eq 1 ]; then
  37. + # Launch Namecoin in verbose mode
  38. + echo "Launching Namecoin..."
  39. + grep --quiet "__LeaveStreamsUnattached 1" TorBrowser/Data/Tor/torrc-defaults || echo "__LeaveStreamsUnattached 1" >> TorBrowser/Data/Tor/torrc-defaults
  40. + TorBrowser/Electrum-NMC/run_electrum_nmc daemon -v --dir "TorBrowser/Data/Electrum-NMC/" &
  41. + ELECTRUM_NMC_PID=$!
  42. + python3 TorBrowser/StemNS/poc.py &
  43. + STEM_NS_PID=$!
  44. + echo "Launched Namecoin."
  45. + else
  46. + # Launch Namecoin
  47. + grep --quiet "__LeaveStreamsUnattached 1" TorBrowser/Data/Tor/torrc-defaults || echo "__LeaveStreamsUnattached 1" >> TorBrowser/Data/Tor/torrc-defaults
  48. + TorBrowser/Electrum-NMC/run_electrum_nmc daemon --dir "TorBrowser/Data/Electrum-NMC/" &
  49. + ELECTRUM_NMC_PID=$!
  50. + python3 TorBrowser/StemNS/poc.py &
  51. + STEM_NS_PID=$!
  52. + fi
  53. +fi
  54. +
  55. +if [ "${TOR_ENABLE_NAMECOIN}" != 1 ]; then
  56. + perl -i -p -e 's/__LeaveStreamsUnattached 1\n//' TorBrowser/Data/Tor/torrc-defaults
  57. +fi
  58. +
  59. if [ "$show_usage" -eq 1 ]; then
  60. # Display Firefox help, then our help
  61. TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
  62. @@ -373,4 +419,13 @@
  63. -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
  64. fi
  65. -exit $?
  66. +FIREFOX_EXIT_CODE=$?
  67. +
  68. +if [ "${TOR_ENABLE_NAMECOIN}" = 1 ]; then
  69. + echo "Terminating Namecoin..."
  70. + kill ${ELECTRUM_NMC_PID}
  71. + kill -s SIGKILL ${STEM_NS_PID}
  72. + echo "Terminated Namecoin."
  73. +fi
  74. +
  75. +exit ${FIREFOX_EXIT_CODE}