mirror of https://github.com/CIRCL/lookyloo
fix: error in UAs, typing
parent
07515bcb40
commit
812c63b0f2
|
@ -11,7 +11,7 @@ from datetime import datetime
|
||||||
from io import BufferedIOBase
|
from io import BufferedIOBase
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
from typing import Dict, List, Optional, Tuple, Union
|
from typing import Dict, List, Optional, Tuple, Union, Literal
|
||||||
from urllib.parse import urlsplit
|
from urllib.parse import urlsplit
|
||||||
|
|
||||||
from defang import refang # type: ignore
|
from defang import refang # type: ignore
|
||||||
|
@ -103,7 +103,7 @@ class AsyncCapture(AbstractManager):
|
||||||
proxy=to_capture[b'proxy'].decode() if to_capture.get(b'proxy') else None,
|
proxy=to_capture[b'proxy'].decode() if to_capture.get(b'proxy') else None,
|
||||||
os=to_capture[b'os'].decode() if to_capture.get(b'os') else None,
|
os=to_capture[b'os'].decode() if to_capture.get(b'os') else None,
|
||||||
browser=to_capture[b'browser'].decode() if to_capture.get(b'browser') else None,
|
browser=to_capture[b'browser'].decode() if to_capture.get(b'browser') else None,
|
||||||
browser_engine=to_capture[b'browser_engine'].decode() if to_capture.get(b'browser_engine') else None,
|
browser_engine=to_capture[b'browser_engine'].decode() if to_capture.get(b'browser_engine') else None, # type: ignore
|
||||||
device_name=to_capture[b'device_name'].decode() if to_capture.get(b'device_name') else None,
|
device_name=to_capture[b'device_name'].decode() if to_capture.get(b'device_name') else None,
|
||||||
parent=to_capture[b'parent'].decode() if to_capture.get(b'parent') else None
|
parent=to_capture[b'parent'].decode() if to_capture.get(b'parent') else None
|
||||||
)
|
)
|
||||||
|
@ -133,7 +133,7 @@ class AsyncCapture(AbstractManager):
|
||||||
headers: Optional[Dict[str, str]]=None,
|
headers: Optional[Dict[str, str]]=None,
|
||||||
proxy: Optional[Union[str, Dict]]=None, os: Optional[str]=None,
|
proxy: Optional[Union[str, Dict]]=None, os: Optional[str]=None,
|
||||||
browser: Optional[str]=None, parent: Optional[str]=None,
|
browser: Optional[str]=None, parent: Optional[str]=None,
|
||||||
browser_engine: Optional[str]=None,
|
browser_engine: Optional[Literal['chromium', 'firefox', 'webkit']]=None,
|
||||||
device_name: Optional[str]=None,
|
device_name: Optional[str]=None,
|
||||||
viewport: Optional[Dict[str, int]]=None) -> Tuple[bool, str]:
|
viewport: Optional[Dict[str, int]]=None) -> Tuple[bool, str]:
|
||||||
'''Launch a capture'''
|
'''Launch a capture'''
|
||||||
|
|
|
@ -95,12 +95,12 @@ class UserAgents:
|
||||||
self.path = get_homedir() / 'user_agents'
|
self.path = get_homedir() / 'user_agents'
|
||||||
|
|
||||||
ua_files_path = sorted(self.path.glob('**/*.json'), reverse=True)
|
ua_files_path = sorted(self.path.glob('**/*.json'), reverse=True)
|
||||||
self._load_newest_ua_file(ua_files_path[0])
|
|
||||||
# This call *must* be here because otherwise, we get the devices from within the async
|
# This call *must* be here because otherwise, we get the devices from within the async
|
||||||
# process and as we already have a playwright context, it fails.
|
# process and as we already have a playwright context, it fails.
|
||||||
# it is not a problem to have it here because the devices do not change
|
# it is not a problem to have it here because the devices do not change
|
||||||
# until we have a new version playwright, and restart everything anyway.
|
# until we have a new version playwright, and restart everything anyway.
|
||||||
self.playwright_devices = get_devices()
|
self.playwright_devices = get_devices()
|
||||||
|
self._load_newest_ua_file(ua_files_path[0])
|
||||||
|
|
||||||
def _load_newest_ua_file(self, path: Path):
|
def _load_newest_ua_file(self, path: Path):
|
||||||
self.most_recent_ua_path = path
|
self.most_recent_ua_path = path
|
||||||
|
|
Loading…
Reference in New Issue