mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-07-01 18:56:40 +00:00
issue 26: now check if the response from sxc is test result if not it will retry
This commit is contained in:
parent
b653171e84
commit
f394e8ef2f
2 changed files with 55 additions and 53 deletions
|
@ -1,9 +1,12 @@
|
|||
import random
|
||||
import re
|
||||
import os
|
||||
import requests
|
||||
from PIL import Image
|
||||
import json
|
||||
#from SimpleX.utils import IsUrlValid
|
||||
import urllib.parse
|
||||
from websockets.sync.client import connect
|
||||
|
||||
|
||||
PURPLE = '\033[35;40m'
|
||||
|
@ -362,4 +365,21 @@ def IsSimpleXUrlValid(url:str)->bool:
|
|||
return False
|
||||
return True
|
||||
|
||||
def send_server_checks(url:str) -> ():
|
||||
"""
|
||||
Sends requests to sxc websocket and retuns
|
||||
response, response type and testFailure or None.
|
||||
"""
|
||||
with connect(f"ws://localhost:3030") as websocket:
|
||||
query = f"/_server test 1 {url}"
|
||||
command = {
|
||||
'corrId': f"id{random.randint(0,999999)}",
|
||||
'cmd': query,
|
||||
}
|
||||
websocket.send(json.dumps(command))
|
||||
message = websocket.recv()
|
||||
response = json.loads(message)
|
||||
resp_type = response["resp"]["type"]
|
||||
failed_response = response['resp'].get('testFailure')
|
||||
|
||||
return (response, resp_type, failed_response)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue