From 0315d638350569c6b25e11e086998e375109d3dd Mon Sep 17 00:00:00 2001 From: Max K <40246850+sttlr@users.noreply.github.com> Date: Wed, 21 May 2025 19:40:05 +0300 Subject: [PATCH 1/6] fix: add organisation field to RIPE search --- orgia/nics/ripe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orgia/nics/ripe.py b/orgia/nics/ripe.py index 998f482..4ffd840 100644 --- a/orgia/nics/ripe.py +++ b/orgia/nics/ripe.py @@ -6,7 +6,7 @@ class RIPE(Engine): DELAY = 0 RESULTS_PER_PAGE = 1000 DB_URL = f'https://apps.db.ripe.net/db-web-ui/api/rest/fulltextsearch/select?facet=false&format=xml&hl=true&wt=json&rows={RESULTS_PER_PAGE}' - ORG_QUERY = '(descr:("{org_name}") OR e-mail:("{org_name}") OR org-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:organisation)' + ORG_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR e-mail:("{org_name}") OR org-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:organisation)' INET_QUERY = '(descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inetnum)' INET6_QUERY = '(descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inet6num)' ASN_QUERY = '(descr:("{org_name}") OR as-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:aut-num)' From 3c1e657d7f9b277183656ac6565f7bf2fb124bb9 Mon Sep 17 00:00:00 2001 From: Max K <40246850+sttlr@users.noreply.github.com> Date: Wed, 21 May 2025 19:48:08 +0300 Subject: [PATCH 2/6] fix add organisation field to other queries --- orgia/nics/ripe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/orgia/nics/ripe.py b/orgia/nics/ripe.py index 4ffd840..b4cc73d 100644 --- a/orgia/nics/ripe.py +++ b/orgia/nics/ripe.py @@ -7,9 +7,9 @@ class RIPE(Engine): RESULTS_PER_PAGE = 1000 DB_URL = f'https://apps.db.ripe.net/db-web-ui/api/rest/fulltextsearch/select?facet=false&format=xml&hl=true&wt=json&rows={RESULTS_PER_PAGE}' ORG_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR e-mail:("{org_name}") OR org-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:organisation)' - INET_QUERY = '(descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inetnum)' - INET6_QUERY = '(descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inet6num)' - ASN_QUERY = '(descr:("{org_name}") OR as-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:aut-num)' + INET_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inetnum)' + INET6_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inet6num)' + ASN_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR as-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:aut-num)' RDAP_URL = 'https://rdap.db.ripe.net' def __init__(self, org_name: str, args): From a7904d4500f8ef81bfec0cefb20737a279d4f5e1 Mon Sep 17 00:00:00 2001 From: Max K <40246850+sttlr@users.noreply.github.com> Date: Wed, 21 May 2025 19:54:44 +0300 Subject: [PATCH 3/6] fix: remove organisation field from other queries --- orgia/nics/ripe.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/orgia/nics/ripe.py b/orgia/nics/ripe.py index b4cc73d..4ffd840 100644 --- a/orgia/nics/ripe.py +++ b/orgia/nics/ripe.py @@ -7,9 +7,9 @@ class RIPE(Engine): RESULTS_PER_PAGE = 1000 DB_URL = f'https://apps.db.ripe.net/db-web-ui/api/rest/fulltextsearch/select?facet=false&format=xml&hl=true&wt=json&rows={RESULTS_PER_PAGE}' ORG_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR e-mail:("{org_name}") OR org-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:organisation)' - INET_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inetnum)' - INET6_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inet6num)' - ASN_QUERY = '(organisation:("{org_name}") OR descr:("{org_name}") OR as-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:aut-num)' + INET_QUERY = '(descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inetnum)' + INET6_QUERY = '(descr:("{org_name}") OR netname:("{org_name}") OR remarks:("{org_name}")) AND (object-type:inet6num)' + ASN_QUERY = '(descr:("{org_name}") OR as-name:("{org_name}") OR remarks:("{org_name}")) AND (object-type:aut-num)' RDAP_URL = 'https://rdap.db.ripe.net' def __init__(self, org_name: str, args): From 798060a6995505a908562defb6207920962fd6d7 Mon Sep 17 00:00:00 2001 From: Max K <40246850+sttlr@users.noreply.github.com> Date: Wed, 21 May 2025 20:05:16 +0300 Subject: [PATCH 4/6] feat: add country search field to ripe --- orgia/nics/ripe.py | 5 ++++- orgia/orgia.py | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/orgia/nics/ripe.py b/orgia/nics/ripe.py index 4ffd840..f9aff74 100644 --- a/orgia/nics/ripe.py +++ b/orgia/nics/ripe.py @@ -23,8 +23,11 @@ def _request_db(self, query: str, page_num: int=0) -> dict: r = self._http_request(url, headers={'Accept': 'application/json'}) return r.json() - def _search_db_and_get_all_pages(self, query: str) -> list: + def _search_db_and_get_all_pages(self, query: str, country: str=None) -> list: query = query.format(org_name=self.org_name) + if country: + query += ' AND (country:("RU"))' + pages = [self._request_db(query)] num_pages = (pages[0]['result']['numFound'] // self.RESULTS_PER_PAGE) + 1 diff --git a/orgia/orgia.py b/orgia/orgia.py index 9359de1..87300ba 100644 --- a/orgia/orgia.py +++ b/orgia/orgia.py @@ -125,6 +125,11 @@ def get_args(): action='store_true' ) + parser.add_argument( + '--country', + help='filter results by country' + ) + args = parser.parse_args() if not any(( From 33c33bf72abf8694ad46cd4578471e38188b3463 Mon Sep 17 00:00:00 2001 From: Max K <40246850+sttlr@users.noreply.github.com> Date: Wed, 21 May 2025 20:14:02 +0300 Subject: [PATCH 5/6] fix country search field --- orgia/nics/ripe.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/orgia/nics/ripe.py b/orgia/nics/ripe.py index f9aff74..a0bca41 100644 --- a/orgia/nics/ripe.py +++ b/orgia/nics/ripe.py @@ -23,9 +23,9 @@ def _request_db(self, query: str, page_num: int=0) -> dict: r = self._http_request(url, headers={'Accept': 'application/json'}) return r.json() - def _search_db_and_get_all_pages(self, query: str, country: str=None) -> list: + def _search_db_and_get_all_pages(self, query: str) -> list: query = query.format(org_name=self.org_name) - if country: + if self.args.country: query += ' AND (country:("RU"))' pages = [self._request_db(query)] From fe5526a3b2b348f8e366d0475ce28c9f3e3e07a8 Mon Sep 17 00:00:00 2001 From: Max K <40246850+sttlr@users.noreply.github.com> Date: Wed, 9 Jul 2025 16:59:26 +0300 Subject: [PATCH 6/6] fix: use selr.args.country --- orgia/nics/ripe.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/orgia/nics/ripe.py b/orgia/nics/ripe.py index a0bca41..05ab43d 100644 --- a/orgia/nics/ripe.py +++ b/orgia/nics/ripe.py @@ -26,7 +26,7 @@ def _request_db(self, query: str, page_num: int=0) -> dict: def _search_db_and_get_all_pages(self, query: str) -> list: query = query.format(org_name=self.org_name) if self.args.country: - query += ' AND (country:("RU"))' + query += f' AND (country:("{self.args.country}"))' pages = [self._request_db(query)]