mirror of
https://github.com/Justuser3310/jetwork.git
synced 2025-01-19 01:18:48 +00:00
Ловим краши
This commit is contained in:
parent
817c713011
commit
c1ddda30ab
81
network.py
81
network.py
@ -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()
|
||||
try:
|
||||
host = "127.0.0.1"
|
||||
port = 8001
|
||||
|
||||
print("Connection from: " + str(address))
|
||||
s = socket.socket()
|
||||
s.bind((host, port))
|
||||
|
||||
while True:
|
||||
try:
|
||||
op = conn.recv(1024).decode()
|
||||
except:
|
||||
pass
|
||||
if not op:
|
||||
break
|
||||
while True:
|
||||
s.listen(2)
|
||||
conn, address = s.accept()
|
||||
|
||||
if op == "ping":
|
||||
conn.send("pong".encode())
|
||||
elif op[:3] == "is_":
|
||||
check = op[3:]
|
||||
# Защита от доступа выше и т.п.
|
||||
check = domain_ok(check)
|
||||
print("Connection from: " + str(address))
|
||||
|
||||
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}")
|
||||
while True:
|
||||
try:
|
||||
op = conn.recv(1024).decode()
|
||||
except:
|
||||
pass
|
||||
if not op:
|
||||
break
|
||||
|
||||
conn.close()
|
||||
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
|
||||
|
13
updater.py
13
updater.py
@ -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…
Reference in New Issue
Block a user