Introduce pluggable proxy configurators
This commit is contained in:
parent
2bd75b87bd
commit
ec11632297
4
setup.py
4
setup.py
|
@ -16,6 +16,7 @@ EXTRAS_REQUIRE = {
|
||||||
'prctl': ['python_prctl'], # Named threads
|
'prctl': ['python_prctl'], # Named threads
|
||||||
'qrcode': ['qrcode'],
|
'qrcode': ['qrcode'],
|
||||||
'sound;platform_system=="Windows"': ['winsound'],
|
'sound;platform_system=="Windows"': ['winsound'],
|
||||||
|
'tor': ['stem'],
|
||||||
'docs': [
|
'docs': [
|
||||||
'sphinx', # fab build_docs
|
'sphinx', # fab build_docs
|
||||||
'graphviz', # fab build_docs
|
'graphviz', # fab build_docs
|
||||||
|
@ -147,6 +148,9 @@ if __name__ == "__main__":
|
||||||
'libmessaging ='
|
'libmessaging ='
|
||||||
'pybitmessage.plugins.indicator_libmessaging [gir]'
|
'pybitmessage.plugins.indicator_libmessaging [gir]'
|
||||||
],
|
],
|
||||||
|
'bitmessage.proxyconfig': [
|
||||||
|
'stem = pybitmessage.plugins.proxyconfig_stem [tor]'
|
||||||
|
],
|
||||||
# 'console_scripts': [
|
# 'console_scripts': [
|
||||||
# 'pybitmessage = pybitmessage.bitmessagemain:main'
|
# 'pybitmessage = pybitmessage.bitmessagemain:main'
|
||||||
# ]
|
# ]
|
||||||
|
|
|
@ -184,6 +184,27 @@ def signal_handler(signum, frame):
|
||||||
|
|
||||||
|
|
||||||
class Main:
|
class Main:
|
||||||
|
@staticmethod
|
||||||
|
def start_proxyconfig(config):
|
||||||
|
"""Check socksproxytype and start any proxy configuration plugin"""
|
||||||
|
proxy_type = config.safeGet('bitmessagesettings', 'socksproxytype')
|
||||||
|
if proxy_type not in ('none', 'SOCKS4a', 'SOCKS5'):
|
||||||
|
# pylint: disable=relative-import
|
||||||
|
from plugins.plugin import get_plugin
|
||||||
|
try:
|
||||||
|
proxyconfig_start = time.time()
|
||||||
|
get_plugin('proxyconfig', name=proxy_type)(config)
|
||||||
|
except TypeError:
|
||||||
|
logger.error(
|
||||||
|
'Failed to run proxy config plugin %s',
|
||||||
|
proxy_type, exc_info=True)
|
||||||
|
shutdown.doCleanShutdown()
|
||||||
|
sys.exit(2)
|
||||||
|
else:
|
||||||
|
logger.info(
|
||||||
|
'Started proxy config plugin %s in %s sec',
|
||||||
|
proxy_type, time.time() - proxyconfig_start)
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
_fixSocket()
|
_fixSocket()
|
||||||
|
|
||||||
|
@ -343,6 +364,7 @@ class Main:
|
||||||
|
|
||||||
# start network components if networking is enabled
|
# start network components if networking is enabled
|
||||||
if state.enableNetwork:
|
if state.enableNetwork:
|
||||||
|
self.start_proxyconfig(config)
|
||||||
BMConnectionPool()
|
BMConnectionPool()
|
||||||
asyncoreThread = BMNetworkThread()
|
asyncoreThread = BMNetworkThread()
|
||||||
asyncoreThread.daemon = True
|
asyncoreThread.daemon = True
|
||||||
|
|
Loading…
Reference in New Issue
Block a user