Started code to add proxy support built in

This commit is contained in:
Manuel Cortez 2019-01-14 04:58:17 -06:00
parent 70a511a141
commit 758907a660
2 changed files with 17 additions and 1 deletions

View File

@ -2,3 +2,4 @@
username = string(default="") username = string(default="")
password = string(default="") password = string(default="")
language = string(default="system") language = string(default="system")
use_proxy = boolean(default=False)

View File

@ -19,9 +19,18 @@ from mysc.thread_utils import call_threaded
log = logging.getLogger("main") log = logging.getLogger("main")
orig_session_init = None
def setup(): def setup():
global orig_session_init
log.debug("Starting Socializer %s" % (application.version,)) log.debug("Starting Socializer %s" % (application.version,))
config.setup() config.setup()
if config.app["app-settings"]["use_proxy"]:
log.debug("Enabling proxy support... ")
import requests
orig_session_init=requests.sessions.Session.__init__
requests.sessions.Session.__init__=patched_session_init
requests.Session.__init__=patched_session_init
log.debug("Using %s %s" % (platform.system(), platform.architecture()[0])) log.debug("Using %s %s" % (platform.system(), platform.architecture()[0]))
log.debug("Application path is %s" % (paths.app_path(),)) log.debug("Application path is %s" % (paths.app_path(),))
log.debug("config path is %s" % (paths.config_path(),)) log.debug("config path is %s" % (paths.config_path(),))
@ -39,4 +48,10 @@ def setup():
call_threaded(r.login) call_threaded(r.login)
app.run() app.run()
def patched_session_init(self):
global orig_session_init
orig_session_init(self)
self.proxies={"http": "http://code.manuelcortez.net:3128",
"https": "http://code.manuelcortez.net:3128"}
setup() setup()