|
|
@ -18,7 +18,7 @@ from domain_check import *
|
|
|
|
# 1. [+] Пинг
|
|
|
|
# 1. [+] Пинг
|
|
|
|
# 2. [+] Проверка существования сайта
|
|
|
|
# 2. [+] Проверка существования сайта
|
|
|
|
# 3. [+] Передача сайта
|
|
|
|
# 3. [+] Передача сайта
|
|
|
|
# 4. Приём рассылки сайтов
|
|
|
|
# 4. [+] Приём рассылки сайтов
|
|
|
|
# 5. Проверка всех сайтов
|
|
|
|
# 5. Проверка всех сайтов
|
|
|
|
|
|
|
|
|
|
|
|
def port_gen():
|
|
|
|
def port_gen():
|
|
|
@ -51,6 +51,7 @@ def server(http_port):
|
|
|
|
while True:
|
|
|
|
while True:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
op = conn.recv(1024).decode()
|
|
|
|
op = conn.recv(1024).decode()
|
|
|
|
|
|
|
|
print(op)
|
|
|
|
except:
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
pass
|
|
|
|
if not op:
|
|
|
|
if not op:
|
|
|
@ -60,22 +61,28 @@ def server(http_port):
|
|
|
|
conn.send("pong".encode())
|
|
|
|
conn.send("pong".encode())
|
|
|
|
elif op[:3] == "is_":
|
|
|
|
elif op[:3] == "is_":
|
|
|
|
check = op[3:]
|
|
|
|
check = op[3:]
|
|
|
|
print(check)
|
|
|
|
# Защита от доступа выше и т.п.
|
|
|
|
# Защита от доступа выше
|
|
|
|
|
|
|
|
check = domain_ok(check)
|
|
|
|
check = domain_ok(check)
|
|
|
|
print(check)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if os.path.exists(f'cached/{check}'):
|
|
|
|
if os.path.exists(f'cached/{check}'):
|
|
|
|
conn.send(str(http_port).encode())
|
|
|
|
conn.send(str(http_port).encode())
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
conn.send("not_exist".encode())
|
|
|
|
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()
|
|
|
|
conn.close()
|
|
|
|
|
|
|
|
|
|
|
|
# op = operation
|
|
|
|
# op = operation
|
|
|
|
def client(port, op = "ping"):
|
|
|
|
def client(port, op = "ping"):
|
|
|
|
host = 'jetwork.404.mn'
|
|
|
|
host = 'jetwork.404.mn'
|
|
|
|
|
|
|
|
|
|
|
|
if op == "ping" or op[:3] == "is_":
|
|
|
|
if op == "ping" or op[:3] == "is_" or op[:8] == "publish_":
|
|
|
|
s = socket.socket()
|
|
|
|
s = socket.socket()
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
s.connect((host, port))
|
|
|
|
s.connect((host, port))
|
|
|
|