Ловим краши

main
none 9 months ago
parent 817c713011
commit c1ddda30ab

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

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

Loading…
Cancel
Save