forked from joepie91/python-whois
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 in ~GEDEELD/the-whois-oracle from feature/VOY-1…
…468-detect-requests-exceeded to develop * commit 'b0f201e9797179e61c31076009d9750d1ee4253e': ENH: Wording in a comment REF: Removed the fix for parsing empty responses and moved it to the whois application that uses this REF: Processed Wytse his comments REF: Renamed whois_response.py to raw_whois_response.py REF: Made timeout an argument, but with a default value REF: Increased default cool down length from 1 second to 2 REF: Extracted the starting of a cool down to a separate method ADD: Can now check whether a rate limit has been exceeded or not FIX: If there are now results at all, parse.py simply returns an empty dictionary instead of crashing ADD: A holder for WHOIS responses. It contains information about the success of the retrieval.
- Loading branch information
Showing
7 changed files
with
118 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
class RawWhoisResponse: | ||
""" | ||
Holder class for WHOIS responses. Is capable of marking the retrieval as a failure. | ||
""" | ||
|
||
def __init__(self, response="", request_failure=False, still_in_cool_down=False, server_is_dead=False): | ||
""" | ||
Hold the WHOIS response | ||
:param response: The received response, if any | ||
:param request_failure: If the request was a failure | ||
:param still_in_cool_down: Whether the server was unavailable due to a cool down or not | ||
""" | ||
self.response = response | ||
self.request_failure = request_failure | ||
self.still_in_cool_down = still_in_cool_down | ||
self.server_is_dead = server_is_dead | ||
|
||
if len(response) > 0: | ||
self.request_failure = self.check_for_exceeded_limit() | ||
|
||
def check_for_exceeded_limit(self): | ||
""" | ||
Check whether the limit has been exceeded. This is done by | ||
looking at the size of the response. If it has less than 4 lines, | ||
it is probably not a useful response and most likely a message about spamming | ||
the WHOIS server | ||
:return: True if the message is really short, false if not | ||
""" | ||
return self.response is not None and len(self.response.splitlines()) < 4 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters