mirror of
http://git.nowherejezfoltodf4jiyl6r56jnzintap5vyjlia7fkirfsnfizflqd.onion/nihilist/darknet-lantern.git
synced 2025-07-01 17:26: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 pandas as pd
|
||||
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__))
|
||||
env_path = os.path.join(script_abs_path+"/.env")
|
||||
|
@ -87,61 +87,43 @@ def main():
|
|||
index1 = url.find("http://")
|
||||
index2 = url.find("https://")
|
||||
|
||||
|
||||
|
||||
if url.startswith("smp://") or url.startswith("xftp://"):
|
||||
if IsSimpleXServerValid(url):
|
||||
with connect(f"ws://localhost:3030") as websocket:
|
||||
if url.startswith("smp"):
|
||||
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 url.startswith("smp"):
|
||||
resp,resp_type,failed_response = send_server_checks(url)
|
||||
|
||||
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:
|
||||
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']['testFailure']
|
||||
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 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
|
||||
else:
|
||||
resp,resp_type,failed_response = send_server_checks(url)
|
||||
|
||||
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:
|
||||
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
|
||||
|
||||
|
||||
else:
|
||||
|
|
|
@ -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