diff --git a/onionr/netcontroller/netcontrol.py b/onionr/netcontroller/netcontrol.py index f7b0746d..8f4be3c1 100644 --- a/onionr/netcontroller/netcontrol.py +++ b/onionr/netcontroller/netcontrol.py @@ -24,6 +24,20 @@ from . import getopenport from utils import identifyhome config.reload() TOR_KILL_WAIT = 3 + +def add_bridges(torrc: str)->str: + """Configure tor to use a bridge using Onionr config keys""" + if config.get('tor.use_bridge', False) == True: + bridge = config.get('tor.bridge_ip', None) + if not bridge is None: + fingerprint = config.get('tor.bridge_fingerprint', '') # allow blank fingerprint purposefully + torrc += '\nUseBridges 1\nBridge %s %s\n' % (bridge, fingerprint) + else: + logger.warn('bridge was enabled but not specified in config') + + return torrc + + class NetController: ''' This class handles hidden service setup on Tor and I2P @@ -90,6 +104,8 @@ HiddenServiceMaxStreams 100 HiddenServiceMaxStreamsCloseCircuit 1 HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort) + torrcData = add_bridges(torrcData) + torrc = open(self.torConfigLocation, 'w') torrc.write(torrcData) torrc.close() diff --git a/onionr/static-data/default_config.json b/onionr/static-data/default_config.json index 6f96bbf1..c378050a 100755 --- a/onionr/static-data/default_config.json +++ b/onionr/static-data/default_config.json @@ -61,7 +61,10 @@ }, "tor" : { - "v3onions" : true + "v3onions" : true, + "use_bridge": false, + "bridge_ip": "", + "bridge_fingerprint": "" }, "i2p" : {