Skip to content

Commit 2c61087

Browse files
committed
Added connection timeout to streams
Fixed bug in "stats" command where numeric facets would error out
1 parent 7a2bbe2 commit 2c61087

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

bin/shodan

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ def get_banner_field(banner, flat_field):
105105

106106
def match_filters(banner, filters):
107107
for args in filters:
108-
flat_field, check = args.split(':')
108+
flat_field, check = args.split(':', 1)
109109
value = get_banner_field(banner, flat_field)
110110

111111
# It must match all filters to be allowed
@@ -1009,7 +1009,7 @@ def stats(limit, facets, query):
10091009
click.echo('Top {} Results for Facet: {}'.format(limit, facet))
10101010

10111011
for item in results['facets'][facet]:
1012-
click.echo(click.style('{:28s}'.format(item['value'].encode('ascii', errors='replace')), fg='cyan'), nl=False)
1012+
click.echo(click.style('{:28s}'.format(str(item['value']).encode('ascii', errors='replace')), fg='cyan'), nl=False)
10131013
click.echo(click.style('{:12,d}'.format(item['count']), fg='green'))
10141014

10151015
click.echo('')
@@ -1048,9 +1048,9 @@ def stream(color, fields, separator, limit, datadir, ports, quiet, streamer):
10481048

10491049
# Decide which stream to subscribe to based on whether or not ports were selected
10501050
if ports:
1051-
stream = api.stream.ports(ports)
1051+
stream = api.stream.ports(ports, timeout=5)
10521052
else:
1053-
stream = api.stream.banners()
1053+
stream = api.stream.banners(timeout=5)
10541054

10551055
counter = 0
10561056
quit = False

0 commit comments

Comments
 (0)