mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-07-02 06:46:42 +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
|
@ -8,10 +8,10 @@ import requests
|
||||||
import json
|
import json
|
||||||
import pandas as pd
|
import pandas as pd
|
||||||
import glob
|
import glob
|
||||||
from utils import IsSimpleXServerValid
|
from utils import IsSimpleXServerValid, send_server_checks
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
from websockets.sync.client import connect
|
|
||||||
|
|
||||||
script_abs_path = os.path.dirname(os.path.abspath(__file__))
|
script_abs_path = os.path.dirname(os.path.abspath(__file__))
|
||||||
env_path = os.path.join(script_abs_path+"/.env")
|
env_path = os.path.join(script_abs_path+"/.env")
|
||||||
|
@ -87,61 +87,43 @@ def main():
|
||||||
index1 = url.find("http://")
|
index1 = url.find("http://")
|
||||||
index2 = url.find("https://")
|
index2 = url.find("https://")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if url.startswith("smp://") or url.startswith("xftp://"):
|
if url.startswith("smp://") or url.startswith("xftp://"):
|
||||||
if IsSimpleXServerValid(url):
|
if IsSimpleXServerValid(url):
|
||||||
with connect(f"ws://localhost:3030") as websocket:
|
if url.startswith("smp"):
|
||||||
if url.startswith("smp"):
|
resp,resp_type,failed_response = send_server_checks(url)
|
||||||
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)
|
|
||||||
failed_response = response['resp'].get('testFailure')
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if failed_response is None:
|
|
||||||
print(url, "✔️")
|
|
||||||
df.at[i, "Status"]="YES"
|
|
||||||
if df.at[i, "Score"] < 100:
|
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
|
||||||
else:
|
|
||||||
|
|
||||||
print(url,"❌")
|
|
||||||
df.at[i,"Status"]="NO"
|
|
||||||
#if uptime >0 do -1 to the value
|
|
||||||
if df.at[i,"Score"] > 0:
|
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
|
||||||
|
|
||||||
|
if resp_type in ["chatError", "contactSubSummary"]:
|
||||||
|
resp, resp_type,failed_response = send_server_checks(url)
|
||||||
|
|
||||||
|
if failed_response is None:
|
||||||
|
print(url, "✔️")
|
||||||
|
df.at[i, "Status"]="YES"
|
||||||
|
if df.at[i, "Score"] < 100:
|
||||||
|
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
||||||
else:
|
else:
|
||||||
query = f"/_server test 1 {url}"
|
print(url,"❌")
|
||||||
command = {
|
df.at[i,"Status"]="NO"
|
||||||
'corrId': f"id{random.randint(0,999999)}",
|
#if uptime >0 do -1 to the value
|
||||||
'cmd': query,
|
if df.at[i,"Score"] > 0:
|
||||||
}
|
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
||||||
websocket.send(json.dumps(command))
|
|
||||||
message = websocket.recv()
|
|
||||||
response = json.loads(message)
|
|
||||||
failed_response = response['resp']['testFailure']
|
|
||||||
|
|
||||||
|
else:
|
||||||
|
resp,resp_type,failed_response = send_server_checks(url)
|
||||||
|
|
||||||
if failed_response is None:
|
if resp_type in ["chatError", "contactSubSummary"]:
|
||||||
print(url, "✔️")
|
resp, resp_type,failed_response = send_server_checks(url)
|
||||||
df.at[i, "Status"]="YES"
|
|
||||||
if df.at[i, "Score"] < 100:
|
if failed_response is None:
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
print(url, "✔️")
|
||||||
else:
|
df.at[i, "Status"]="YES"
|
||||||
print(url,"❌")
|
if df.at[i, "Score"] < 100:
|
||||||
df.at[i,"Status"]="NO"
|
df.at[i,"Score"] = df.at[i,"Score"] + 1
|
||||||
#if uptime >0 do -1 to the value
|
else:
|
||||||
if df.at[i,"Score"] > 0:
|
print(url,"❌")
|
||||||
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
df.at[i,"Status"]="NO"
|
||||||
|
#if uptime >0 do -1 to the value
|
||||||
|
if df.at[i,"Score"] > 0:
|
||||||
|
df.at[i,"Score"] = df.at[i,"Score"] - 1
|
||||||
|
|
||||||
|
|
||||||
else:
|
else:
|
||||||
|
|
|
@ -1,9 +1,12 @@
|
||||||
|
import random
|
||||||
import re
|
import re
|
||||||
import os
|
import os
|
||||||
import requests
|
import requests
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
import json
|
||||||
#from SimpleX.utils import IsUrlValid
|
#from SimpleX.utils import IsUrlValid
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
|
from websockets.sync.client import connect
|
||||||
|
|
||||||
|
|
||||||
PURPLE = '\033[35;40m'
|
PURPLE = '\033[35;40m'
|
||||||
|
@ -362,4 +365,21 @@ def IsSimpleXUrlValid(url:str)->bool:
|
||||||
return False
|
return False
|
||||||
return True
|
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