Skip to content

Commit abd9e79

Browse files
committed
Bump to 1.10, pin websocket-client, and add --url parameter
1 parent 68a983c commit abd9e79

File tree

4 files changed

+8
-8
lines changed

4 files changed

+8
-8
lines changed

certstream/cli.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
parser.add_argument('--full', action='store_true', help='Output all SAN addresses as well')
1616
parser.add_argument('--disable-colors', action='store_true', help='Disable colors when writing a human readable ')
1717
parser.add_argument('--verbose', action='store_true', default=False, dest='verbose', help='Display debug logging.')
18+
parser.add_argument('--url', default="wss://certstream.calidog.io", dest='url', help='Connect to a certstream server.')
1819

1920
def main():
2021
args = parser.parse_args()
@@ -60,7 +61,7 @@ def _handle_messages(message, context):
6061

6162
sys.stdout.flush()
6263

63-
certstream.listen_for_events(_handle_messages, skip_heartbeats=True)
64+
certstream.listen_for_events(_handle_messages, args.url, skip_heartbeats=True)
6465

6566
if __name__ == "__main__":
6667
main()

certstream/core.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,15 @@ class Context(dict):
1313
__delattr__ = dict.__delitem__
1414

1515
class CertStreamClient(WebSocketApp):
16-
CERTSTREAM_URL = 'wss://certstream.calidog.io'
1716
_context = Context()
1817

19-
def __init__(self, message_callback, skip_heartbeats=True, on_open=None, on_error=None):
18+
def __init__(self, message_callback, url, skip_heartbeats=True, on_open=None, on_error=None):
2019
self.message_callback = message_callback
2120
self.skip_heartbeats = skip_heartbeats
2221
self.on_open_handler = on_open
2322
self.on_error_handler = on_error
2423
super(CertStreamClient, self).__init__(
25-
url=self.CERTSTREAM_URL,
24+
url=url,
2625
on_open=self._on_open,
2726
on_message=self._on_message,
2827
on_error=self._on_error,
@@ -48,13 +47,13 @@ def _on_error(self, instance, ex):
4847
self.on_error_handler(instance, ex)
4948
logging.error("Error connecting to CertStream - {} - Sleeping for a few seconds and trying again...".format(ex))
5049

51-
def listen_for_events(message_callback, skip_heartbeats=True, setup_logger=True, on_open=None, on_error=None, **kwargs):
50+
def listen_for_events(message_callback, url, skip_heartbeats=True, setup_logger=True, on_open=None, on_error=None, **kwargs):
5251
if setup_logger:
5352
logging.basicConfig(format='[%(levelname)s:%(name)s] %(asctime)s - %(message)s', level=logging.INFO)
5453

5554
try:
5655
while True:
57-
c = CertStreamClient(message_callback, skip_heartbeats=skip_heartbeats, on_open=on_open, on_error=on_error)
56+
c = CertStreamClient(message_callback, url, skip_heartbeats=skip_heartbeats, on_open=on_open, on_error=on_error)
5857
c.run_forever(**kwargs)
5958
time.sleep(5)
6059
except KeyboardInterrupt:

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
websocket-client
1+
websocket-client==0.48.0
22
termcolor

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
setup(
1616
name='certstream',
17-
version="1.9",
17+
version="1.10",
1818
url='https://github.com/CaliDog/certstream-python/',
1919
author='Ryan Sears',
2020
install_requires=dependencies,

0 commit comments

Comments
 (0)