namecoin.patch 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. diff -ru RelativeLink/start-tor-browser RelativeLinkNamecoin/start-tor-browser
  2. --- RelativeLink/start-tor-browser 2019-11-03 06:56:36.062938844 +0000
  3. +++ RelativeLinkNamecoin/start-tor-browser 2019-12-13 12:00:58.000000000 +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,55 @@
  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. +terminate_namecoin () {
  21. + echo "Terminating Namecoin..."
  22. + kill ${ELECTRUM_NMC_PID}
  23. + kill -s SIGKILL ${STEM_NS_PID}
  24. + echo "Terminated Namecoin."
  25. +}
  26. +if [ "${TOR_ENABLE_NAMECOIN}" = 1 ]; then
  27. + python3 -c 'import sys; exit(0) if sys.version_info[:2] >= (3, 6) else exit(1)'
  28. + if [ "$?" -ne 0 ]; then
  29. + complain "Namecoin requires at least Python 3.6."
  30. + exit 1
  31. + fi
  32. +
  33. + if [ "$show_usage" -eq 1 ]; then
  34. + # No help exists for Namecoin
  35. + TOR_ENABLE_NAMECOIN=0
  36. + elif [ "$detach" -eq 1 ] ; then
  37. + # No support yet for detached Namecoin
  38. + TOR_ENABLE_NAMECOIN=0
  39. + elif [ "$log_output" -eq 1 -a "$show_output" -eq 1 ]; then
  40. + # No support yet for logging Namecoin
  41. + TOR_ENABLE_NAMECOIN=0
  42. + elif [ "$show_output" -eq 1 ]; then
  43. + # Launch Namecoin in verbose mode
  44. + echo "Launching Namecoin..."
  45. + trap terminate_namecoin SIGINT SIGTERM
  46. + grep --quiet "__LeaveStreamsUnattached 1" TorBrowser/Data/Tor/torrc-defaults || echo "__LeaveStreamsUnattached 1" >> TorBrowser/Data/Tor/torrc-defaults
  47. + TorBrowser/Electrum-NMC/run_electrum_nmc daemon -v --dir "TorBrowser/Data/Electrum-NMC/" &
  48. + ELECTRUM_NMC_PID=$!
  49. + python3 TorBrowser/StemNS/poc.py &
  50. + STEM_NS_PID=$!
  51. + echo "Launched Namecoin."
  52. + else
  53. + # Launch Namecoin
  54. + trap terminate_namecoin SIGINT SIGTERM
  55. + grep --quiet "__LeaveStreamsUnattached 1" TorBrowser/Data/Tor/torrc-defaults || echo "__LeaveStreamsUnattached 1" >> TorBrowser/Data/Tor/torrc-defaults
  56. + TorBrowser/Electrum-NMC/run_electrum_nmc daemon --dir "TorBrowser/Data/Electrum-NMC/" &
  57. + ELECTRUM_NMC_PID=$!
  58. + python3 TorBrowser/StemNS/poc.py &
  59. + STEM_NS_PID=$!
  60. + fi
  61. +fi
  62. +
  63. +if [ "${TOR_ENABLE_NAMECOIN}" != 1 ]; then
  64. + perl -i -p -e 's/__LeaveStreamsUnattached 1\n//' TorBrowser/Data/Tor/torrc-defaults
  65. +fi
  66. +
  67. if [ "$show_usage" -eq 1 ]; then
  68. # Display Firefox help, then our help
  69. TOR_CONTROL_PASSWD=${TOR_CONTROL_PASSWD} ./firefox --class "Tor Browser" \
  70. @@ -373,4 +427,10 @@
  71. -profile TorBrowser/Data/Browser/profile.default "${@}" > "$logfile" 2>&1 </dev/null
  72. fi
  73. -exit $?
  74. +FIREFOX_EXIT_CODE=$?
  75. +
  76. +if [ "${TOR_ENABLE_NAMECOIN}" = 1 ]; then
  77. + terminate_namecoin
  78. +fi
  79. +
  80. +exit ${FIREFOX_EXIT_CODE}