Skip to content

Commit

Permalink
new: Support for proxies to connect to the instance
Browse files Browse the repository at this point in the history
  • Loading branch information
Rafiot committed Nov 21, 2023
1 parent 208fd3d commit b3dcf9f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pyvulnerabilitylookup/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,13 @@

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.
: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

Expand All @@ -24,6 +27,8 @@ def __init__(self, root_url: str, useragent: Optional[str]=None):
self.root_url += '/'
self.session = requests.session()
self.session.headers['user-agent'] = useragent if useragent else f'PyProject / {version("pyvulnerabilitylookup")}'
if proxies:
self.session.proxies.update(proxies)

@property
def is_up(self) -> bool:
Expand Down

0 comments on commit b3dcf9f

Please sign in to comment.