mirror of
https://github.com/cve-search/PyVulnerabilityLookup.git
synced 2024-11-25 16:27:23 +00:00
new: Support for proxies to connect to the instance
This commit is contained in:
parent
208fd3d845
commit
b3dcf9fe57
1 changed files with 6 additions and 1 deletions
|
@ -11,10 +11,13 @@ import requests
|
||||||
|
|
||||||
class PyVulnerabilityLookup():
|
class PyVulnerabilityLookup():
|
||||||
|
|
||||||
def __init__(self, root_url: str, useragent: Optional[str]=None):
|
def __init__(self, root_url: str, useragent: Optional[str]=None,
|
||||||
|
*, proxies: Optional[Dict[str, str]]=None):
|
||||||
'''Query a specific instance.
|
'''Query a specific instance.
|
||||||
|
|
||||||
:param root_url: URL of the instance to query.
|
:param root_url: URL of the instance to query.
|
||||||
|
:param useragent: The User Agent used by requests to run the HTTP requests against the vulnerability lookup instance
|
||||||
|
:param proxies: The proxies to use to connect to the vulnerability lookup instance - More details: https://requests.readthedocs.io/en/latest/user/advanced/#proxies
|
||||||
'''
|
'''
|
||||||
self.root_url = root_url
|
self.root_url = root_url
|
||||||
|
|
||||||
|
@ -24,6 +27,8 @@ class PyVulnerabilityLookup():
|
||||||
self.root_url += '/'
|
self.root_url += '/'
|
||||||
self.session = requests.session()
|
self.session = requests.session()
|
||||||
self.session.headers['user-agent'] = useragent if useragent else f'PyProject / {version("pyvulnerabilitylookup")}'
|
self.session.headers['user-agent'] = useragent if useragent else f'PyProject / {version("pyvulnerabilitylookup")}'
|
||||||
|
if proxies:
|
||||||
|
self.session.proxies.update(proxies)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def is_up(self) -> bool:
|
def is_up(self) -> bool:
|
||||||
|
|
Loading…
Reference in a new issue