Added context to crtsh database query to prevent it from blocking forever if the connection was lost #1190
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The db.Query() call used prior blocks until results have been received. However, if using an unreliable connection (e.g. routing all traffic through Tor), the connection may break, resulting in db.Query() to block forever and as a result for the enumeration to never finish if crtsh was used as a datasource (even if the maximum enumeration time was reached).
This MR is a simple duct-tape fix to query the database with the enumeration context (which is usually a timeout context), so the enumeration will at least always finish after the enumeration timeout was reached. While not a very elegant solution to the problem (we may still be attempting to query a broken connection until the maximum enumeration time is reached), it at least assures that the enumeration actually finishes eventually.