Functions for adding and removing bridge relays

This commit is contained in:
Bob Mottram 2016-12-22 10:41:13 +00:00
parent 2225963992
commit 2171555adf
1 changed files with 44 additions and 1 deletions

View File

@ -418,7 +418,7 @@ function tor_add_bridge {
return return
fi fi
apt-get install obfs4proxy apt-get -yq install obfs4proxy
if grep "ClientTransportPlugin" /etc/tor/torrc; then if grep "ClientTransportPlugin" /etc/tor/torrc; then
sed -i 's|#ClientTransportPlugin|ClientTransportPlugin|g' /etc/tor/torrc sed -i 's|#ClientTransportPlugin|ClientTransportPlugin|g' /etc/tor/torrc
@ -465,4 +465,47 @@ function tor_remove_bridge {
systemctl restart tor 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 # NOTE: deliberately no exit 0