mirror of
https://github.com/MCV-Software/TWBlue.git
synced 2025-01-18 16:40:41 -06:00
Patched requests.sessions.Session.__init__ to get proxy configuration from config. Now TWBlue should be able to connect to http and https proxies with authentication
This commit is contained in:
parent
2c27a1968f
commit
232d39e0b3
@ -1,5 +1,8 @@
|
||||
from requests import certs, utils, adapters
|
||||
import paths
|
||||
import config
|
||||
import requests.sessions
|
||||
orig_session_init=requests.sessions.Session.__init__
|
||||
|
||||
def patched_where():
|
||||
return paths.app_path(u"cacert.pem")
|
||||
@ -8,3 +11,13 @@ def fix():
|
||||
certs.where=patched_where
|
||||
utils.DEFAULT_CA_BUNDLE_PATH=patched_where()
|
||||
adapters.DEFAULT_CA_BUNDLE_PATH=patched_where()
|
||||
requests.sessions.Session.__init__=patched_session_init
|
||||
|
||||
def patched_session_init(self):
|
||||
orig_session_init(self)
|
||||
if config.app["proxy"]["server"] != "" and config.app["proxy"]["port"] != "":
|
||||
self.proxies={"http":"http://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"]),
|
||||
"https": "https://{0}:{1}/".format(config.app["proxy"]["server"], config.app["proxy"]["port"])}
|
||||
if config.app["proxy"]["user"] != "" and config.app["proxy"]["password"] != "":
|
||||
self.proxies={"http": "http://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"]),
|
||||
"https": "https://{0}:{1}@{2}:{3}/".format(config.app["proxy"]["user"], config.app["proxy"]["password"], config.app["proxy"]["server"], config.app["proxy"]["port"])}
|
||||
|
Loading…
x
Reference in New Issue
Block a user