Ловим краши

main
none 9 months ago
parent 817c713011
commit c1ddda30ab

@ -34,50 +34,59 @@ def port_gen():
return port return port
def server_http(): def server_http():
os.chdir("cached") while True:
os.system("python -m http.server") try:
os.chdir("cached")
os.system("python -m http.server")
except:
print("SERVER_HTTP FALLED")
def server(http_port): def server(http_port):
host = "127.0.0.1"
port = 8001
s = socket.socket()
s.bind((host, port))
while True: while True:
s.listen(2) try:
conn, address = s.accept() host = "127.0.0.1"
port = 8001
print("Connection from: " + str(address))
s = socket.socket()
while True: s.bind((host, port))
try:
op = conn.recv(1024).decode() while True:
except: s.listen(2)
pass conn, address = s.accept()
if not op:
break print("Connection from: " + str(address))
if op == "ping": while True:
conn.send("pong".encode()) try:
elif op[:3] == "is_": op = conn.recv(1024).decode()
check = op[3:] except:
# Защита от доступа выше и т.п. pass
check = domain_ok(check) if not op:
break
if os.path.exists(f'cached/{check}'):
conn.send(str(http_port).encode()) if op == "ping":
else: conn.send("pong".encode())
conn.send("not_exist".encode()) elif op[:3] == "is_":
elif op[:8] == "publish_": check = op[3:]
data = op[8:] # Защита от доступа выше и т.п.
site, port = data.split("<>") check = domain_ok(check)
site = domain_ok(site)
if site: if os.path.exists(f'cached/{check}'):
conn.send("accepted".encode()) conn.send(str(http_port).encode())
client(port, f"get_{site}") else:
conn.send("not_exist".encode())
conn.close() elif op[:8] == "publish_":
data = op[8:]
site, port = data.split("<>")
site = domain_ok(site)
if site:
conn.send("accepted".encode())
client(port, f"get_{site}")
conn.close()
except:
print("SERVER FALLED")
def recv(q, s): def recv(q, s):
okay = False okay = False

@ -6,10 +6,13 @@ from network import *
def update_demon(serv_port): def update_demon(serv_port):
while True: while True:
ports = port_check(serv_port) try:
ports = port_check(serv_port)
conf = read() conf = read()
conf["ports"] = ports conf["ports"] = ports
write(conf) write(conf)
sleep(8) sleep(8)
except:
print("UPDATER FALLED")

Loading…
Cancel
Save