diff options
author | Lars-Dominik Braun <lars@6xq.net> | 2019-06-26 16:44:55 +0200 |
---|---|---|
committer | Lars-Dominik Braun <lars@6xq.net> | 2019-06-26 16:47:21 +0200 |
commit | 94be61a303127335eb39b26302392a0f237c3ac1 (patch) | |
tree | 9998581a2c51ff4b65cdfe50f24b0531d62ffef9 /crocoite/controller.py | |
parent | 926b5ac98449764599ff80d99546f8d1f1c438fe (diff) | |
download | crocoite-94be61a303127335eb39b26302392a0f237c3ac1.tar.gz crocoite-94be61a303127335eb39b26302392a0f237c3ac1.tar.bz2 crocoite-94be61a303127335eb39b26302392a0f237c3ac1.zip |
Allow turning off cert validation
Add --insecure switch (shamelessly stolen from CURL) to both, -grab and
-irc.
Diffstat (limited to 'crocoite/controller.py')
-rw-r--r-- | crocoite/controller.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/crocoite/controller.py b/crocoite/controller.py index 1bcca0f..02017c3 100644 --- a/crocoite/controller.py +++ b/crocoite/controller.py @@ -35,14 +35,19 @@ from .util import getFormattedViewportMetrics, getSoftwareInfo from .behavior import ExtractLinksEvent class ControllerSettings: - __slots__ = ('idleTimeout', 'timeout') + __slots__ = ('idleTimeout', 'timeout', 'insecure') - def __init__ (self, idleTimeout=2, timeout=10): + def __init__ (self, idleTimeout=2, timeout=10, insecure=False): self.idleTimeout = idleTimeout self.timeout = timeout + self.insecure = insecure def toDict (self): - return dict (idleTimeout=self.idleTimeout, timeout=self.timeout) + return dict ( + idleTimeout=self.idleTimeout, + timeout=self.timeout, + insecure=self.insecure, + ) defaultSettings = ControllerSettings () @@ -204,17 +209,21 @@ class SinglePageController: handle = asyncio.ensure_future (processQueue ()) timeoutProc = asyncio.ensure_future (asyncio.sleep (self.settings.timeout)) + # configure browser + tab = l.tab + await tab.Security.setIgnoreCertificateErrors (ignore=self.settings.insecure) + # not all behavior scripts are allowed for every URL, filter them self._enabledBehavior = list (filter (lambda x: self.url in x, map (lambda x: x (l, logger), self.behavior))) - version = await l.tab.Browser.getVersion () + version = await tab.Browser.getVersion () payload = { 'software': getSoftwareInfo (), 'browser': { 'product': version['product'], 'useragent': version['userAgent'], - 'viewport': await getFormattedViewportMetrics (l.tab), + 'viewport': await getFormattedViewportMetrics (tab), }, 'tool': 'crocoite-single', # not the name of the cli utility 'parameters': { @@ -222,6 +231,7 @@ class SinglePageController: 'idleTimeout': self.settings.idleTimeout, 'timeout': self.settings.timeout, 'behavior': list (map (attrgetter('name'), self._enabledBehavior)), + 'insecure': self.settings.insecure, }, } if self.warcinfo: @@ -264,7 +274,7 @@ class SinglePageController: break await behavior.stop () - await l.tab.Page.stopLoading () + await tab.Page.stopLoading () await asyncio.sleep (1) await behavior.finish () |