2020-08-09 01:44:11 +00:00
|
|
|
"""Onionr - Private P2P Communication.
|
2019-07-14 06:51:43 +00:00
|
|
|
|
2020-08-09 01:44:11 +00:00
|
|
|
Add bridge info to torrc configuration string
|
2019-12-12 08:47:33 +00:00
|
|
|
"""
|
|
|
|
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-12-12 08:47:33 +00:00
|
|
|
"""
|
2019-07-14 06:51:43 +00:00
|
|
|
|
2019-12-12 08:47:33 +00:00
|
|
|
|
|
|
|
def add_bridges(torrc: str) -> str:
|
2020-08-09 01:44:11 +00:00
|
|
|
"""Configure tor to use a bridge using Onionr config keys."""
|
2019-12-12 08:47:33 +00:00
|
|
|
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)
|
|
|
|
else:
|
|
|
|
logger.warn('bridge was enabled but not specified in config')
|
|
|
|
|
|
|
|
return torrc
|