From 2171555adf847ed1e0b35e38143e978464d2bba6 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Thu, 22 Dec 2016 10:41:13 +0000 Subject: [PATCH] Functions for adding and removing bridge relays --- src/freedombone-utils-onion | 45 ++++++++++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/src/freedombone-utils-onion b/src/freedombone-utils-onion index d0989d5e..66f98054 100755 --- a/src/freedombone-utils-onion +++ b/src/freedombone-utils-onion @@ -418,7 +418,7 @@ function tor_add_bridge { return fi - apt-get install obfs4proxy + apt-get -yq install obfs4proxy if grep "ClientTransportPlugin" /etc/tor/torrc; then sed -i 's|#ClientTransportPlugin|ClientTransportPlugin|g' /etc/tor/torrc @@ -465,4 +465,47 @@ function tor_remove_bridge { systemctl restart tor } +function tor_create_bridge_relay { + apt-get -yq install obfs4proxy + + sed -i 's|#BridgeRelay.*|BridgeRelay 1|g' /etc/tor/torrc + sed -i 's|BridgeRelay.*|BridgeRelay 1|g' /etc/tor/torrc + sed -i 's|#ServerTransportPlugin.*|ServerTransportPlugin obfs4 exec /usr/bin/obfs4proxy|g' /etc/tor/torrc + sed -i 's|ServerTransportPlugin.*|ServerTransportPlugin obfs4 exec /usr/bin/obfs4proxy|g' /etc/tor/torrc + if ! grep "ExtORPort auto" /etc/tor/torrc; then + echo 'ExtORPort auto' >> /etc/tor/torrc + else + sed -i 's|#ExtORPort auto|ExtORPort auto|g' /etc/tor/torrc + sed -i 's|ExtORPort .*|ExtORPort auto|g' /etc/tor/torrc + fi + + read_config_param MY_'EMAIL_ADDRESS' + read_config_param 'TOR_BRIDGE_NICKNAME' + + sed -i "s|#ContactInfo|ContactInfo $MY_EMAIL_ADDRESS|g" /etc/tor/torrc + if [ $TOR_BRIDGE_NICKNAME ]; then + sed -i "s|#Nickname|Nickname $TOR_BRIDGE_NICKNAME|g" /etc/tor/torrc + fi + systemctl restart tor +} + +function tor_remove_bridge_relay { + if ! grep '#BridgeRelay ' /etc/tor/torrc; then + sed -i 's|BridgeRelay |#BridgeRelay |g' /etc/tor/torrc + fi + if ! grep '#ServerTransportPlugin ' /etc/tor/torrc; then + sed -i 's|ServerTransportPlugin |#ServerTransportPlugin |g' /etc/tor/torrc + fi + if ! grep '#ExtORPort ' /etc/tor/torrc; then + sed -i 's|ExtORPort |#ExtORPort |g' /etc/tor/torrc + fi + if ! grep '#ContactInfo ' /etc/tor/torrc; then + sed -i "s|ContactInfo |#ContactInfo |g" /etc/tor/torrc + fi + if ! grep '#Nickname ' /etc/tor/torrc; then + sed -i "s|Nickname |#Nickname |g" /etc/tor/torrc + fi + systemctl restart tor +} + # NOTE: deliberately no exit 0