Skip to content

Commit

Permalink
Fix relative URL compatibility for RIPE
Browse files Browse the repository at this point in the history
  • Loading branch information
mxsasha committed Nov 13, 2024
1 parent d0ecaf7 commit 7637280
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
14 changes: 9 additions & 5 deletions irrd/mirroring/nrtm4/nrtm4_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def _retrieve_unf(self) -> Tuple[NRTM4UpdateNotificationFile, Optional[str]]:
unf_signed, _ = retrieve_file(self.notification_file_url, return_contents=True)
if "nrtm.db.ripe.net" in self.notification_file_url: # pragma: no cover
# When removing this, also remove Optional[] from return type
logger.warning("Expecting raw UNF as source is RIPE*, signature not checked")
logger.warning("Expecting raw UNF as URL is nrtm.db.ripe.net, signature not checked")
unf_payload = unf_signed.encode("ascii")
used_key = None
else:
Expand Down Expand Up @@ -285,8 +285,11 @@ def _load_snapshot(self, unf: NRTM4UpdateNotificationFile):
Load a snapshot into the database.
Deals with the usual things for bulk loading, like deleting old objects.
"""
url = unf.snapshot.full_url(self.notification_file_url)
if "nrtm.db.ripe.net" in self.notification_file_url: # pragma: no cover
url = unf.snapshot.url
snapshot_path, should_delete = retrieve_file(
unf.snapshot.full_url(self.notification_file_url),
url,
return_contents=False,
expected_hash=unf.snapshot.hash,
)
Expand Down Expand Up @@ -340,9 +343,10 @@ def _load_deltas(self, unf: NRTM4UpdateNotificationFile, next_version: int):
for delta in unf.deltas:
if delta.version < next_version:
continue
delta_path, should_delete = retrieve_file(
delta.full_url(self.notification_file_url), return_contents=False, expected_hash=delta.hash
)
url = delta.full_url(self.notification_file_url)
if "nrtm.db.ripe.net" in self.notification_file_url: # pragma: no cover
url = delta.url
delta_path, should_delete = retrieve_file(url, return_contents=False, expected_hash=delta.hash)
try:
delta_file = open(delta_path, "rb")
delta_iterator = jsonseq_decode(delta_file)
Expand Down
3 changes: 1 addition & 2 deletions irrd/mirroring/nrtm4/nrtm4_types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import datetime
from functools import cached_property
from pathlib import Path
from typing import Any, List, Literal, Optional
from urllib.parse import urlparse, urlunparse
from uuid import UUID
Expand Down Expand Up @@ -75,7 +74,7 @@ class NRTM4FileReference(pydantic.main.BaseModel):
"""

version: pydantic.PositiveInt
url: Path
url: str # Convert to Path when RIPE db is fixed
hash: str

def full_url(self, unf_url: str) -> str:
Expand Down

0 comments on commit 7637280

Please sign in to comment.