lacuscore 1.8.8__py3-none-any.whl → 1.8.9__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
lacuscore/lacuscore.py CHANGED
@@ -29,6 +29,7 @@ from urllib.parse import urlsplit
29
29
 
30
30
  from dns import resolver
31
31
  from dns.exception import DNSException
32
+ from dns.exception import Timeout as DNSTimeout
32
33
 
33
34
  from defang import refang # type: ignore[import-untyped]
34
35
  from playwrightcapture import Capture, PlaywrightCaptureException
@@ -175,6 +176,10 @@ class LacusCore():
175
176
  self.tor_proxy = tor_proxy
176
177
  self.only_global_lookups = only_global_lookups
177
178
  self.max_retries = max_retries
179
+ self.dnsresolver: resolver.Resolver = resolver.Resolver()
180
+ self.dnsresolver.cache = resolver.Cache(30)
181
+ self.dnsresolver.timeout = 2
182
+ self.dnsresolver.lifetime = 3
178
183
 
179
184
  # NOTE: Remove in 1.8.* - clear old ongoing captures queue in case of need
180
185
  if self.redis.type('lacus:ongoing') in ['set', b'set']: # type: ignore[no-untyped-call]
@@ -565,6 +570,10 @@ class LacusCore():
565
570
  # not an IP, try resolving
566
571
  try:
567
572
  ips_to_check = self.__get_ips(logger, splitted_url.hostname)
573
+ except DNSTimeout as e:
574
+ # for a timeout, we do not want to retry, as it is likely to timeout again
575
+ result = {'error': f'DNS Timeout for "{splitted_url.hostname}": {e}'}
576
+ raise CaptureError(f'DNS Timeout for "{splitted_url.hostname}": {e}')
568
577
  except Exception as e:
569
578
  result = {'error': f'Issue with hostname resolution ({splitted_url.hostname}): {e}. Full URL: "{url}".'}
570
579
  raise CaptureError(f'Issue with hostname resolution ({splitted_url.hostname}): {e}. Full URL: "{url}".')
@@ -854,13 +863,17 @@ class LacusCore():
854
863
  # It is happening when the error code is NoAnswer
855
864
  resolved_ips = []
856
865
  try:
857
- answers_a = resolver.resolve(hostname, 'A')
866
+ answers_a = self.dnsresolver.resolve(hostname, 'A')
858
867
  resolved_ips += [ip_address(str(answer)) for answer in answers_a]
868
+ except DNSTimeout as e:
869
+ raise e
859
870
  except DNSException as e:
860
871
  logger.info(f'No A record for "{hostname}": {e}')
861
872
  try:
862
- answers_aaaa = resolver.resolve(hostname, 'AAAA')
873
+ answers_aaaa = self.dnsresolver.resolve(hostname, 'AAAA')
863
874
  resolved_ips += [ip_address(str(answer)) for answer in answers_aaaa]
875
+ except DNSTimeout as e:
876
+ raise e
864
877
  except DNSException as e:
865
878
  logger.info(f'No AAAA record for "{hostname}": {e}')
866
879
  return resolved_ips
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: lacuscore
3
- Version: 1.8.8
3
+ Version: 1.8.9
4
4
  Summary: Core of Lacus, usable as a module
5
5
  Home-page: https://github.com/ail-project/LacusCore
6
6
  License: BSD-3-Clause
@@ -28,8 +28,8 @@ Requires-Dist: Sphinx (>=7.2,<8.0) ; (python_version >= "3.9") and (extra == "do
28
28
  Requires-Dist: async-timeout (>=4.0.3,<5.0.0) ; python_version < "3.11"
29
29
  Requires-Dist: defang (>=0.5.3,<0.6.0)
30
30
  Requires-Dist: dnspython (>=2.6.1,<3.0.0)
31
- Requires-Dist: playwrightcapture[recaptcha] (>=1.23.9,<2.0.0)
32
- Requires-Dist: redis[hiredis] (>=5.0.2,<6.0.0)
31
+ Requires-Dist: playwrightcapture[recaptcha] (>=1.23.10,<2.0.0)
32
+ Requires-Dist: redis[hiredis] (>=5.0.3,<6.0.0)
33
33
  Requires-Dist: requests (>=2.31.0,<3.0.0)
34
34
  Requires-Dist: ua-parser (>=0.18.0,<0.19.0)
35
35
  Project-URL: Documentation, https://lacuscore.readthedocs.io/en/latest/
@@ -0,0 +1,8 @@
1
+ lacuscore/__init__.py,sha256=10JsUmjLD9xQIsjTDYT5nGowsJVe9C-FHNkaUFuAUtU,321
2
+ lacuscore/lacus_monitoring.py,sha256=UOfE_1-_rhVeKJXQ_m9XxYkr7VwyQnA6iK-x_tcXJfo,2775
3
+ lacuscore/lacuscore.py,sha256=iI1Cz9gnhQo8dw7gPII_vCsGHB_wzv-_9cpB3jRDizw,43901
4
+ lacuscore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
+ lacuscore-1.8.9.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
6
+ lacuscore-1.8.9.dist-info/METADATA,sha256=L1ITEAiio8MB6NUSn-Yi9tAL6BaYMnz-VVKFg_2IX-A,2629
7
+ lacuscore-1.8.9.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
8
+ lacuscore-1.8.9.dist-info/RECORD,,
@@ -1,8 +0,0 @@
1
- lacuscore/__init__.py,sha256=10JsUmjLD9xQIsjTDYT5nGowsJVe9C-FHNkaUFuAUtU,321
2
- lacuscore/lacus_monitoring.py,sha256=UOfE_1-_rhVeKJXQ_m9XxYkr7VwyQnA6iK-x_tcXJfo,2775
3
- lacuscore/lacuscore.py,sha256=hZNlx2atJdVB3XDxH61Qxc8ZjJD99zNTcodkckvFz0M,43177
4
- lacuscore/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
5
- lacuscore-1.8.8.dist-info/LICENSE,sha256=4C4hLYrIkUD96Ggk-y_Go1Qf7PBZrEm9PSeTGe2nd4s,1516
6
- lacuscore-1.8.8.dist-info/METADATA,sha256=BrcE5dNEMyGxT8U4bMkkJDGCorEOU2f4cPM5Hy4ug_g,2628
7
- lacuscore-1.8.8.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
8
- lacuscore-1.8.8.dist-info/RECORD,,