added basic tor bridge support.

fixes #35
This commit is contained in:
Kevin Froman 2019-09-06 04:31:13 -05:00
parent 3be83699db
commit d0fab00e3b
No known key found for this signature in database
GPG Key ID: 0D414D0FE405B63B
2 changed files with 20 additions and 1 deletions

View File

@ -24,6 +24,20 @@ from . import getopenport
from utils import identifyhome from utils import identifyhome
config.reload() config.reload()
TOR_KILL_WAIT = 3 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: class NetController:
''' '''
This class handles hidden service setup on Tor and I2P This class handles hidden service setup on Tor and I2P
@ -90,6 +104,8 @@ HiddenServiceMaxStreams 100
HiddenServiceMaxStreamsCloseCircuit 1 HiddenServiceMaxStreamsCloseCircuit 1
HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort) HiddenServicePort 80 ''' + self.apiServerIP + ''':''' + str(self.hsPort)
torrcData = add_bridges(torrcData)
torrc = open(self.torConfigLocation, 'w') torrc = open(self.torConfigLocation, 'w')
torrc.write(torrcData) torrc.write(torrcData)
torrc.close() torrc.close()

View File

@ -61,7 +61,10 @@
}, },
"tor" : { "tor" : {
"v3onions" : true "v3onions" : true,
"use_bridge": false,
"bridge_ip": "",
"bridge_fingerprint": ""
}, },
"i2p" : { "i2p" : {