Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the quipqiup module #29

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

313ctric
Copy link

@313ctric 313ctric commented Jan 6, 2021

Fix issue #27 by using the actual quipqiup site as the existing api always returns a 500 (Internal Server Error) response code.

It works, but I don't like having to set the verify=False with requests as this stops certificate validation which makes it less secure.
I also dislike using sleep(), but I can't think of a better way to wait for the server.

@calebstewart
Copy link
Collaborator

The only comment I would have is we could utilize the interval returned by the API call in the same way the web interface does instead of waiting the maximum amount of time. It would mean more web requests, but a possibly shorter wait time. @JohnHammond do you have an opinion either way here?

@313ctric
Copy link
Author

313ctric commented Jan 9, 2021

This code waits for it to solve by requesting every poll_interval until it returns last (finished flag) as 1 or we take too long.
It is about 0.5-1 second(s) faster, and in testing sent 3 rather than 2 requests so is probably worth the change.

from time import time as curr_time

...

data = {"ciphertext":cipher,"clues":clues,"mode":"auto","was_auto":True,"was_clue":False}
solve_response = json.loads( requests.post(url, data=json.dumps(data), headers=headers, verify=False).text )
    
url = "https://quipqiup.com/status"
data = {"id":solve_response["id"]}
status_response = json.loads( requests.post(url, data=json.dumps(data), headers=headers, verify=False).text )

start_time = curr_time()

while (curr_time() - start_time) <= min(solve_response["max_time"], time) and status_response["last"] != 1:
    sleep( min(solve_response["poll_interval"], time) )
    status_response = json.loads( requests.post(url, data=json.dumps(data), headers=headers, verify=False).text )

return json.dumps(status_response)

@eljeffeg
Copy link
Contributor

@calebstewart is this PR good to merge? The current version is broken, so would be good to have some fix applied.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants