Onionr/src/netcontroller/torcontrol/addbridges.py

37 lines
1.4 KiB
Python
Raw Normal View History

"""Onionr - Private P2P Communication.
2019-07-14 06:51:43 +00:00
Add bridge info to torrc configuration string
"""
import config
import logger
"""
2019-07-14 06:51:43 +00:00
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
2019-07-14 06:51:43 +00:00
def add_bridges(torrc: str) -> str:
"""Configure tor to use a bridge using Onionr config keys."""
2020-08-12 04:49:26 +00:00
config.reload()
if config.get('tor.use_bridge', False) is True:
bridge = config.get('tor.bridge_ip', None)
if bridge is not None:
# allow blank fingerprint purposefully
fingerprint = config.get('tor.bridge_fingerprint', '')
torrc += '\nUseBridges 1\nBridge %s %s\n' % (bridge, fingerprint)
if not bridge:
2020-08-12 04:49:26 +00:00
logger.error('Bridge was enabled but not specified in config, ' +
'this probably won\'t work', terminal=True)
return torrc