pybgpkit 0.4.2__tar.gz → 0.4.3__tar.gz
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.
- {pybgpkit-0.4.2/pybgpkit.egg-info → pybgpkit-0.4.3}/PKG-INFO +1 -1
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/bgpkit/bgpkit_broker.py +8 -3
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/bgpkit/test_integration.py +8 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3/pybgpkit.egg-info}/PKG-INFO +1 -1
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/setup.py +1 -1
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/LICENSE +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/README.md +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/bgpkit/__init__.py +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/bgpkit/bgpkit_parser.py +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/bgpkit/bgpkit_roas.py +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/pybgpkit.egg-info/SOURCES.txt +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/pybgpkit.egg-info/dependency_links.txt +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/pybgpkit.egg-info/requires.txt +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/pybgpkit.egg-info/top_level.txt +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/pyproject.toml +0 -0
- {pybgpkit-0.4.2 → pybgpkit-0.4.3}/setup.cfg +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
from dataclasses import dataclass
|
|
2
2
|
|
|
3
3
|
import requests as requests
|
|
4
|
+
import urllib3
|
|
4
5
|
|
|
5
6
|
|
|
6
7
|
def check_type(value: any, ty: type) -> bool:
|
|
@@ -24,9 +25,13 @@ class BrokerItem:
|
|
|
24
25
|
|
|
25
26
|
class Broker:
|
|
26
27
|
|
|
27
|
-
def __init__(self, api_url: str = "https://api.broker.bgpkit.com/v2", page_size: int = 100):
|
|
28
|
+
def __init__(self, api_url: str = "https://api.broker.bgpkit.com/v2", page_size: int = 100, verify=True):
|
|
28
29
|
self.base_url = api_url.strip()
|
|
29
30
|
self.page_size = int(page_size)
|
|
31
|
+
self.verify = verify
|
|
32
|
+
if not verify:
|
|
33
|
+
# if a user disable SSL verification on-purpose, do not warn the user
|
|
34
|
+
urllib3.disable_warnings()
|
|
30
35
|
|
|
31
36
|
def query(self,
|
|
32
37
|
ts_start: str = None,
|
|
@@ -58,7 +63,7 @@ class Broker:
|
|
|
58
63
|
data_items = []
|
|
59
64
|
if print_url:
|
|
60
65
|
print(api_url)
|
|
61
|
-
res = requests.get(api_url).json()
|
|
66
|
+
res = requests.get(api_url, verify=self.verify).json()
|
|
62
67
|
while res:
|
|
63
68
|
if res["count"] > 0:
|
|
64
69
|
data_items.extend([BrokerItem(**i) for i in res["data"]])
|
|
@@ -70,7 +75,7 @@ class Broker:
|
|
|
70
75
|
query_url = f"{api_url}&page={page}"
|
|
71
76
|
if print_url:
|
|
72
77
|
print(query_url)
|
|
73
|
-
res = requests.get(query_url).json()
|
|
78
|
+
res = requests.get(query_url, verify=self.verify).json()
|
|
74
79
|
else:
|
|
75
80
|
break
|
|
76
81
|
|
|
@@ -31,6 +31,14 @@ class TestIntegration(unittest.TestCase):
|
|
|
31
31
|
print(len(items))
|
|
32
32
|
assert len(items) == 7
|
|
33
33
|
|
|
34
|
+
def test_broker_no_verify(self):
|
|
35
|
+
broker = bgpkit.Broker(verify=False)
|
|
36
|
+
items = broker.query(ts_start="1643760000", ts_end="2022-02-02T00:20:00", collector_id="rrc00")
|
|
37
|
+
for item in items:
|
|
38
|
+
print(json.dumps(item.__dict__))
|
|
39
|
+
print(len(items))
|
|
40
|
+
assert len(items) == 7
|
|
41
|
+
|
|
34
42
|
def test_roas(self):
|
|
35
43
|
roas = bgpkit.Roas()
|
|
36
44
|
data = roas.query(debug=True, asn=3333, date="2018-01-01")
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|