freedombone-utils-onion 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. #!/bin/bash
  2. #
  3. # .---. . .
  4. # | | |
  5. # |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
  6. # | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
  7. # ' ' --' --' -' - -' ' ' -' -' -' ' - --'
  8. #
  9. # Freedom in the Cloud
  10. #
  11. # Onion functions
  12. #
  13. # License
  14. # =======
  15. #
  16. # Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
  17. #
  18. # This program is free software: you can redistribute it and/or modify
  19. # it under the terms of the GNU Affero General Public License as published by
  20. # the Free Software Foundation, either version 3 of the License, or
  21. # (at your option) any later version.
  22. #
  23. # This program is distributed in the hope that it will be useful,
  24. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  25. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  26. # GNU Affero General Public License for more details.
  27. #
  28. # You should have received a copy of the GNU Affero General Public License
  29. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  30. function add_email_hostname {
  31. extra_email_hostname="$1"
  32. email_hostnames=$(cat /etc/exim4/update-exim4.conf.conf | grep "dc_other_hostnames" | awk -F "'" '{print $2}')
  33. if [[ "$email_hostnames" != *"$extra_email_hostname"* ]]; then
  34. sed -i "s|dc_other_hostnames=.*|dc_other_hostnames='$emailhostnames;extra_email_hostname'|g" /etc/exim4/update-exim4.conf.conf
  35. update-exim4.conf
  36. dpkg-reconfigure --frontend noninteractive exim4-config
  37. systemctl restart saslauthd
  38. fi
  39. }
  40. function onion_update {
  41. # update so that new onion services appear
  42. systemctl reload tor
  43. }
  44. function onion_service_exists {
  45. onion_service_name="$1"
  46. if [ -f /var/lib/tor/hidden_service_${onion_service_name}/hostname ]; then
  47. echo "1"
  48. else
  49. echo "0"
  50. fi
  51. }
  52. function wait_for_onion_service_base {
  53. onion_service_name="$1"
  54. sleep_ctr=0
  55. while [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; do
  56. sleep 1
  57. sleep_ctr=$((sleep_ctr + 1))
  58. if [ $sleep_ctr -gt 10 ]; then
  59. break
  60. fi
  61. done
  62. }
  63. function wait_for_onion_service {
  64. onion_service_name="$1"
  65. wait_for_onion_service_base ${onion_service_name}
  66. if [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; then
  67. # try a second time
  68. onion_update
  69. wait_for_onion_service_base ${onion_service_name}
  70. fi
  71. }
  72. function remove_onion_service {
  73. onion_service_name="$1"
  74. onion_service_port_to=$2
  75. #sed -i "/stealth ${onion_service_name}/d" /etc/tor/torrc
  76. sed -i "/hidden_service_${onion_service_name}/d" /etc/tor/torrc
  77. sed -i "/hidden_service_${onion_service_name}_mobile/d" /etc/tor/torrc
  78. sed -i "/127.0.0.1:${onion_service_port_to}/d" /etc/tor/torrc
  79. if [ $3 ]; then
  80. sed -i "/127.0.0.1:${3}/d" /etc/tor/torrc
  81. if [ $4 ]; then
  82. sed -i "/127.0.0.1:${4}/d" /etc/tor/torrc
  83. if [ $5 ]; then
  84. sed -i "/127.0.0.1:${5}/d" /etc/tor/torrc
  85. fi
  86. fi
  87. fi
  88. if [ -d /var/lib/tor/hidden_service_${onion_service_name} ]; then
  89. shred -zu /var/lib/tor/hidden_service_${onion_service_name}/*
  90. rm -rf /var/lib/tor/hidden_service_${onion_service_name}
  91. fi
  92. if [ -d /var/lib/tor/hidden_service_${onion_service_name}_mobile ]; then
  93. shred -zu /var/lib/tor/hidden_service_${onion_service_name}_mobile/*
  94. rm -rf /var/lib/tor/hidden_service_${onion_service_name}_mobile
  95. fi
  96. remove_completion_param "${onion_service_name} onion domain"
  97. onion_update
  98. }
  99. function add_onion_service {
  100. onion_service_name="$1"
  101. onion_service_port_from=$2
  102. onion_service_port_to=$3
  103. if [[ $(onion_service_exists ${onion_service_name}) == "1" ]]; then
  104. echo $(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
  105. return
  106. fi
  107. if [ ! -d /var/lib/tor ]; then
  108. echo $"No Tor installation found. ${onion_service_name} onion site cannot be configured."
  109. exit 877367
  110. fi
  111. if ! grep -q "hidden_service_${onion_service_name}" /etc/tor/torrc; then
  112. echo "HiddenServiceDir /var/lib/tor/hidden_service_${onion_service_name}/" >> /etc/tor/torrc
  113. echo "HiddenServicePort ${onion_service_port_from} 127.0.0.1:${onion_service_port_to}" >> /etc/tor/torrc
  114. #echo "HiddenServiceAuthorizeClient stealth ${onion_service_name}" >> /etc/tor/torrc
  115. fi
  116. onion_update
  117. function_check wait_for_onion_service
  118. wait_for_onion_service ${onion_service_name}
  119. if [[ $(onion_service_exists ${onion_service_name}) == "0" ]]; then
  120. echo $"${onion_service_name} onion site hostname not found"
  121. exit 76362
  122. fi
  123. onion_address=$(cat /var/lib/tor/hidden_service_${onion_service_name}/hostname)
  124. # Record the domain in the completion file
  125. set_completion_param "${onion_service_name} onion domain" "${onion_address}"
  126. echo $onion_address
  127. }
  128. function set_default_onion_domains {
  129. # If sites are only visible via Tor then for installation
  130. # purposes assign them some default domain names
  131. if [[ $ONION_ONLY == "no" ]]; then
  132. return
  133. fi
  134. POSTACTIV_DOMAIN_NAME='postactiv.local'
  135. GNUSOCIAL_DOMAIN_NAME='gnusocial.local'
  136. HTMLY_DOMAIN_NAME='htmly.local'
  137. GHOST_DOMAIN_NAME='ghost.local'
  138. DOKUWIKI_DOMAIN_NAME='dokuwiki.local'
  139. DEFAULT_DOMAIN_NAME="${PROJECT_NAME}.local"
  140. GIT_DOMAIN_NAME='gogs.local'
  141. }
  142. function create_avahi_onion_domains {
  143. if [[ $SYSTEM_TYPE == "mesh"* ]]; then
  144. return
  145. fi
  146. if [ ! -d /etc/avahi/services ]; then
  147. return
  148. fi
  149. if [ $GNUSOCIAL_DOMAIN_NAME ]; then
  150. function_check create_avahi_service
  151. create_avahi_service gnusocial http tcp $GNUSOCIAL_ONION_PORT
  152. fi
  153. if [ $HTMLY_DOMAIN_NAME ]; then
  154. function_check create_avahi_service
  155. create_avahi_service blog http tcp $HTMLY_ONION_PORT
  156. fi
  157. if [ $GIT_DOMAIN_NAME ]; then
  158. function_check create_avahi_service
  159. create_avahi_service git http tcp $GIT_ONION_PORT
  160. fi
  161. if [ $DOKUWIKI_DOMAIN_NAME ]; then
  162. function_check create_avahi_service
  163. create_avahi_service dokuwiki http tcp $DOKUWIKI_ONION_PORT
  164. fi
  165. }
  166. function allow_ssh_to_onion_address {
  167. if [[ $SYSTEM_TYPE == "mesh"* ]]; then
  168. return
  169. fi
  170. if [ ! -d /home/$MY_USERNAME/.ssh ]; then
  171. mkdir /home/$MY_USERNAME/.ssh
  172. fi
  173. if [ ! -d /etc/tor ]; then
  174. echo $'Tor not found when updating ssh'
  175. exit 528257
  176. fi
  177. if ! grep -q "onion" /home/$MY_USERNAME/.ssh/config; then
  178. echo 'Host *.onion' >> /home/$MY_USERNAME/.ssh/config
  179. echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> /home/$MY_USERNAME/.ssh/config
  180. fi
  181. }
  182. function enable_ssh_via_onion {
  183. if [[ $SYSTEM_TYPE == "mesh"* ]]; then
  184. return
  185. fi
  186. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  187. return
  188. fi
  189. apt-get -yq install tor connect-proxy
  190. if ! grep -q 'Host *.onion' /home/$MY_USERNAME/.ssh/config; then
  191. if [ ! -d /home/$MY_USERNAME/.ssh ]; then
  192. mkdir /home/$MY_USERNAME/.ssh
  193. fi
  194. echo 'Host *.onion' >> /home/$MY_USERNAME/.ssh/config
  195. echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> /home/$MY_USERNAME/.ssh/config
  196. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh
  197. chown $MY_USERNAME:$MY_USERNAME /home/$MY_USERNAME/.ssh/config
  198. fi
  199. if ! grep -q 'Host *.onion' /root/.ssh/config; then
  200. if [ ! -d /root/.ssh ]; then
  201. mkdir /root/.ssh
  202. fi
  203. echo 'Host *.onion' >> /root/.ssh/config
  204. echo 'ProxyCommand connect -R remote -5 -S 127.0.0.1:9050 %h %p' >> /root/.ssh/config
  205. fi
  206. mark_completed $FUNCNAME
  207. }
  208. function configure_ssh_onion {
  209. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  210. return
  211. fi
  212. if [[ $SYSTEM_TYPE == "mesh"* ]]; then
  213. return
  214. fi
  215. SSH_ONION_HOSTNAME=$(add_onion_service ssh ${SSH_PORT} ${SSH_PORT})
  216. set_completion_param "ssh onion domain" "${SSH_ONION_HOSTNAME}"
  217. add_email_hostname "${SSH_ONION_HOSTNAME}"
  218. mark_completed $FUNCNAME
  219. }
  220. function install_tor {
  221. if [[ $SYSTEM_TYPE == "mesh*" ]]; then
  222. return
  223. fi
  224. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  225. return
  226. fi
  227. apt-get -yq install tor
  228. if [ ! -f /etc/tor/torrc ]; then
  229. echo 'Tor failed to install'
  230. exit 38259
  231. fi
  232. # turn off logging
  233. sed -i 's|#Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
  234. sed -i 's|Log notice file.*|Log notice file /dev/null|g' /etc/tor/torrc
  235. mark_completed $FUNCNAME
  236. }
  237. function resolve_dns_via_tor {
  238. if [[ $SYSTEM_TYPE == "mesh"* ]]; then
  239. return
  240. fi
  241. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  242. return
  243. fi
  244. if [ ! -f /etc/tor/torrc ]; then
  245. echo $'tor was not installed'
  246. exit 52952
  247. fi
  248. # resolve DNS via tor
  249. if ! grep 'DNSPort 53' /etc/tor/torrc; then
  250. echo 'DNSPort 53' >> /etc/tor/torrc
  251. echo 'AutomapHostsOnResolve 1' >> /etc/tor/torrc
  252. echo 'AutomapHostsSuffixes .exit,.onion' >> /etc/tor/torrc
  253. onion_update
  254. fi
  255. # don't change resolv.conf
  256. sed -i 's|, domain-name-servers||g' /etc/dhcp/dhclient.conf
  257. # point resolv.conf to tor
  258. echo 'nameserver 127.0.0.1:53' > /etc/resolv.conf
  259. # prevent resolv.conf from changing
  260. chattr +i /etc/resolv.conf
  261. mark_completed $FUNCNAME
  262. }
  263. # see https://trac.torproject.org/projects/tor/wiki/doc/TransparentProxy
  264. # Local Redirection and Anonymizing Middlebox
  265. function route_outgoing_traffic_through_tor {
  266. if [[ $(is_completed $FUNCNAME) == "1" ]]; then
  267. return
  268. fi
  269. if [[ $ROUTE_THROUGH_TOR != "yes" ]]; then
  270. return
  271. fi
  272. apt-get -yq install tor tor-arm
  273. ### set variables
  274. # Destinations you don't want routed through Tor
  275. _non_tor="192.168.1.0/24 192.168.0.0/24"
  276. # The user that Tor runs as
  277. _tor_uid="debian-tor"
  278. # Tor's TransPort
  279. _trans_port="9040"
  280. # Your internal interface
  281. _int_if="eth0"
  282. ### Set iptables *nat
  283. iptables -t nat -A OUTPUT -o lo -j RETURN
  284. iptables -t nat -A OUTPUT -m owner --uid-owner $_tor_uid -j RETURN
  285. iptables -t nat -A OUTPUT -p udp --dport 53 -j REDIRECT --to-ports 53
  286. # Allow clearnet access for hosts in $_non_tor
  287. for _clearnet in $_non_tor; do
  288. iptables -t nat -A OUTPUT -d $_clearnet -j RETURN
  289. iptables -t nat -A PREROUTING -i $_int_if -d $_clearnet -j RETURN
  290. done
  291. # Redirect all other pre-routing and output to Tor
  292. iptables -t nat -A OUTPUT -p tcp --syn -j REDIRECT --to-ports $_trans_port
  293. iptables -t nat -A PREROUTING -i $_int_if -p udp --dport 53 -j REDIRECT --to-ports 53
  294. iptables -t nat -A PREROUTING -i $_int_if -p tcp --syn -j REDIRECT --to-ports $_trans_port
  295. ### set iptables *filter
  296. iptables -A OUTPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  297. # Allow clearnet access for hosts in $_non_tor
  298. for _clearnet in $_non_tor 127.0.0.0/8; do
  299. iptables -A OUTPUT -d $_clearnet -j ACCEPT
  300. done
  301. # Allow only Tor output
  302. iptables -A OUTPUT -m owner --uid-owner $_tor_uid -j ACCEPT
  303. iptables -A OUTPUT -j REJECT
  304. function_check save_firewall_settings
  305. save_firewall_settings
  306. if ! grep -q "fs.file-max" /etc/sysctl.conf; then
  307. echo "fs.file-max=100000" >> /etc/sysctl.conf
  308. /sbin/sysctl -p -q
  309. fi
  310. echo 'domain localdomain' > /etc/resolv.conf
  311. echo 'search localdomain' >> /etc/resolv.conf
  312. echo 'nameserver 127.0.0.1' >> /etc/resolv.conf
  313. if ! grep -q "VirtualAddrNetworkIPv4" /etc/tor/torrc; then
  314. echo 'VirtualAddrNetworkIPv4 10.192.0.0/10' >> /etc/tor/torrc
  315. fi
  316. if ! grep -q "AutomapHostsOnResolve" /etc/tor/torrc; then
  317. echo 'AutomapHostsOnResolve 1' >> /etc/tor/torrc
  318. fi
  319. if ! grep -q "TransPort" /etc/tor/torrc; then
  320. echo 'TransPort 9040' >> /etc/tor/torrc
  321. fi
  322. if ! grep -q "TransListenAddress 127.0.0.1" /etc/tor/torrc; then
  323. echo 'TransListenAddress 127.0.0.1' >> /etc/tor/torrc
  324. fi
  325. if ! grep -q "TransListenAddress $LOCAL_NETWORK_STATIC_IP_ADDRESS" /etc/tor/torrc; then
  326. echo "TransListenAddress $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/tor/torrc
  327. fi
  328. if ! grep -q "DNSPort" /etc/tor/torrc; then
  329. echo 'DNSPort 53' >> /etc/tor/torrc
  330. fi
  331. if ! grep -q "DNSListenAddress 127.0.0.1" /etc/tor/torrc; then
  332. echo 'DNSListenAddress 127.0.0.1' >> /etc/tor/torrc
  333. fi
  334. if ! grep -q "DNSListenAddress $LOCAL_NETWORK_STATIC_IP_ADDRESS" /etc/tor/torrc; then
  335. echo "DNSListenAddress $LOCAL_NETWORK_STATIC_IP_ADDRESS" >> /etc/tor/torrc
  336. fi
  337. mark_completed $FUNCNAME
  338. }
  339. function get_app_onion_address {
  340. app_name="$1"
  341. mobilestr="$2"
  342. if [ ${#mobilestr} -gt 0 ]; then
  343. mobilestr="_${mobilestr}"
  344. fi
  345. if grep -q "${app_name}${mobilestr} onion domain" $COMPLETION_FILE; then
  346. if grep -q "${app_name}${mobilestr} onion domain" $COMPLETION_FILE; then
  347. echo $(cat ${COMPLETION_FILE} | grep "${app_name}${mobilestr} onion domain" | head -n 1 | awk -F ':' '{print $2}')
  348. return
  349. fi
  350. fi
  351. echo ""
  352. }
  353. function tor_add_bridge {
  354. bridge_ip_address="$1"
  355. bridge_port="$2"
  356. bridge_key="$3"
  357. bridge_type='obfs4'
  358. if [[ "$bridge_ip_address" != *"."* ]]; then
  359. return
  360. fi
  361. if [ ${#bridge_port} -eq 0 ]; then
  362. return
  363. fi
  364. if [ ${#bridge_key} -eq 0 ]; then
  365. return
  366. fi
  367. apt-get -yq install obfs4proxy
  368. if grep -q "ClientTransportPlugin" /etc/tor/torrc; then
  369. sed -i 's|#ClientTransportPlugin|ClientTransportPlugin|g' /etc/tor/torrc
  370. sed -i 's|# ClientTransportPlugin|ClientTransportPlugin|g' /etc/tor/torrc
  371. sed -i 's|ClientTransportPlugin.*|ClientTransportPlugin obfs4 exec /usr/bin/obfs4proxy managed|g' /etc/tor/torrc
  372. else
  373. echo 'ClientTransportPlugin obfs4 exec /usr/bin/obfs4proxy managed' >> /etc/tor/torrc
  374. fi
  375. if grep -q "UseBridges" /etc/tor/torrc; then
  376. sed -i 's|#UseBridges|UseBridges|g' /etc/tor/torrc
  377. sed -i 's|# UseBridges|UseBridges|g' /etc/tor/torrc
  378. sed -i 's|UseBridges.*|UseBridges 1|g' /etc/tor/torrc
  379. else
  380. echo 'UseBridges 1' >> /etc/tor/torrc
  381. fi
  382. bridge_str="Bridge $bridge_type ${bridge_ip_address}:${bridge_port} ${bridge_key}"
  383. if ! grep -q "${bridge_str}" /etc/tor/torrc; then
  384. sed -i "/UseBridges/a ${bridge_str}" >> /etc/tor/torrc
  385. fi
  386. systemctl restart tor
  387. }
  388. function tor_remove_bridge {
  389. bridge_ip_address="$1"
  390. bridge_type='obfs4'
  391. if [[ "$bridge_ip_address" == *"."* ]]; then
  392. bridge_str="Bridge $bridge_type ${bridge_ip_address}"
  393. else
  394. if grep -q " ${bridge_ip_address}" /etc/tor/torrc; then
  395. bridge_str=" ${bridge_ip_address}"
  396. else
  397. return
  398. fi
  399. fi
  400. if grep -q "${bridge_str}" /etc/tor/torrc; then
  401. sed -i "/${bridge_str}/d" /etc/tor/torrc
  402. fi
  403. # If there are no bridges remaining then remove UseBridges
  404. if ! grep -q "Bridge " /etc/tor/torrc; then
  405. if ! grep -q "#UseBridges" /etc/tor/torrc; then
  406. sed -i 's|UseBridges|#UseBridges|g' /etc/tor/torrc
  407. fi
  408. if ! grep -q "#ClientTransportPlugin" /etc/tor/torrc; then
  409. sed -i 's|ClientTransportPlugin|#ClientTransportPlugin|g' /etc/tor/torrc
  410. fi
  411. fi
  412. systemctl restart tor
  413. }
  414. function tor_create_bridge_relay {
  415. read_config_param 'TOR_BRIDGE_PORT'
  416. read_config_param 'TOR_BRIDGE_NICKNAME'
  417. if [ ! $TOR_BRIDGE_PORT ]; then
  418. return
  419. fi
  420. if [ ${#TOR_BRIDGE_PORT} -eq 0 ]; then
  421. return
  422. fi
  423. if [ ${#TOR_BRIDGE_NICKNAME} -eq 0 ]; then
  424. return
  425. fi
  426. apt-get -yq install obfs4proxy
  427. sed -i 's|#BridgeRelay.*|BridgeRelay 1|g' /etc/tor/torrc
  428. sed -i 's|BridgeRelay.*|BridgeRelay 1|g' /etc/tor/torrc
  429. sed -i 's|#ServerTransportPlugin.*|ServerTransportPlugin obfs4 exec /usr/bin/obfs4proxy|g' /etc/tor/torrc
  430. sed -i 's|ServerTransportPlugin.*|ServerTransportPlugin obfs4 exec /usr/bin/obfs4proxy|g' /etc/tor/torrc
  431. if ! grep -q 'ExtORPort ' /etc/tor/torrc; then
  432. echo "ExtORPort $TOR_BRIDGE_PORT" >> /etc/tor/torrc
  433. else
  434. sed -i "s|#ExtORPort .*|ExtORPort $TOR_BRIDGE_PORT|g" /etc/tor/torrc
  435. sed -i "s|ExtORPort .*|ExtORPort $TOR_BRIDGE_PORT|g" /etc/tor/torrc
  436. fi
  437. read_config_param 'MY_EMAIL_ADDRESS'
  438. sed -i "s|#ContactInfo.*|ContactInfo $MY_EMAIL_ADDRESS|g" /etc/tor/torrc
  439. if [ $TOR_BRIDGE_NICKNAME ]; then
  440. sed -i "s|#Nickname.*|Nickname $TOR_BRIDGE_NICKNAME|g" /etc/tor/torrc
  441. sed -i "s|Nickname.*|Nickname $TOR_BRIDGE_NICKNAME|g" /etc/tor/torrc
  442. fi
  443. firewall_add tor_bridge $TOR_BRIDGE_PORT tcp
  444. systemctl restart tor
  445. }
  446. function tor_remove_bridge_relay {
  447. if ! grep -q '#BridgeRelay ' /etc/tor/torrc; then
  448. sed -i 's|BridgeRelay |#BridgeRelay |g' /etc/tor/torrc
  449. fi
  450. if ! grep -q '#ServerTransportPlugin ' /etc/tor/torrc; then
  451. sed -i 's|ServerTransportPlugin |#ServerTransportPlugin |g' /etc/tor/torrc
  452. fi
  453. if ! grep -q '#ExtORPort ' /etc/tor/torrc; then
  454. sed -i 's|ExtORPort |#ExtORPort |g' /etc/tor/torrc
  455. fi
  456. if ! grep -q '#ContactInfo ' /etc/tor/torrc; then
  457. sed -i "s|ContactInfo |#ContactInfo |g" /etc/tor/torrc
  458. fi
  459. if ! grep -q '#Nickname ' /etc/tor/torrc; then
  460. sed -i "s|Nickname |#Nickname |g" /etc/tor/torrc
  461. fi
  462. read_config_param 'TOR_BRIDGE_PORT'
  463. firewall_remove $TOR_BRIDGE_PORT tcp
  464. systemctl restart tor
  465. }
  466. # NOTE: deliberately no exit 0