mirror of
https://github.com/Justuser3310/jetwork.git
synced 2025-02-07 17:34:39 +00:00
Compare commits
11 Commits
d6559d0e68
...
cca41a5d7a
Author | SHA1 | Date | |
---|---|---|---|
|
cca41a5d7a | ||
|
4074b07f15 | ||
|
2f797096d0 | ||
|
cd8c321aec | ||
|
94f7b1a773 | ||
|
ab84313def | ||
|
cec4b07b4a | ||
|
0f35ab55fe | ||
|
dbaded283b | ||
|
b559b7b659 | ||
|
a383517634 |
22
README.md
22
README.md
@ -13,6 +13,7 @@ https://t.me/justuser31_chat
|
||||
|
||||
## 📋 Содержание
|
||||
- ▶️ Начало работы
|
||||
- 🌐 Установка на сервер
|
||||
- 🔓 Открытие любых портов
|
||||
- 📎 Публикация статичного сайта
|
||||
- 📎 Публикация динамичного сайта
|
||||
@ -32,6 +33,8 @@ https://t.me/justuser31_chat
|
||||
3. Установить tar: `sudo apt install tar`
|
||||
4. Клонировать репозиторий: `git clone https://github.com/Justuser3310/jetwork.git`
|
||||
5. Запустить setup.py: `cd jetwork && python setup.py`
|
||||
6. Запустить клиент: `python main.py`
|
||||
7. Зайти на `http://127.0.0.1:5555`
|
||||
|
||||
<br>
|
||||
<br>
|
||||
@ -41,6 +44,25 @@ https://t.me/justuser31_chat
|
||||
2. Установить git: https://git-scm.com/download/win (Windows setup)
|
||||
3. Клонировать репозиторий: `git clone https://github.com/Justuser3310/jetwork.git`
|
||||
4. Запустить setup.py: `cd jetwork && python setup.py`
|
||||
5. Запустить клиент: `python main.py`
|
||||
6. Зайти на `http://127.0.0.1:5555`
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
#### 📱 Termux
|
||||
Следовать инструкции для Linux.
|
||||
Только заменить `sudo apt` на `pkg` в 1-3 шагах.
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
||||
### 🌐 Начало работы
|
||||
|
||||
1. Выполнить шаги в начале работы до 5 включительно (Linux) или 4 (Windows)
|
||||
2. Запустить серверный клиент: `python srv_main.py`
|
||||
( Отключён скан портов, чтобы снизить нагрузку и избежать утечки памяти )
|
||||
3. Зайти на `http://127.0.0.1:5555`
|
||||
|
||||
<br>
|
||||
<br>
|
||||
|
BIN
__pycache__/db.cpython-311.pyc
Normal file
BIN
__pycache__/db.cpython-311.pyc
Normal file
Binary file not shown.
BIN
__pycache__/domain_check.cpython-311.pyc
Normal file
BIN
__pycache__/domain_check.cpython-311.pyc
Normal file
Binary file not shown.
BIN
__pycache__/network.cpython-311.pyc
Normal file
BIN
__pycache__/network.cpython-311.pyc
Normal file
Binary file not shown.
BIN
__pycache__/proxy.cpython-311.pyc
Normal file
BIN
__pycache__/proxy.cpython-311.pyc
Normal file
Binary file not shown.
BIN
__pycache__/status.cpython-311.pyc
Normal file
BIN
__pycache__/status.cpython-311.pyc
Normal file
Binary file not shown.
BIN
__pycache__/updater.cpython-311.pyc
Normal file
BIN
__pycache__/updater.cpython-311.pyc
Normal file
Binary file not shown.
BIN
__pycache__/verify.cpython-311.pyc
Normal file
BIN
__pycache__/verify.cpython-311.pyc
Normal file
Binary file not shown.
BIN
assets/favicon.ico
Normal file
BIN
assets/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 103 KiB |
67
assets/style.css
Normal file
67
assets/style.css
Normal file
@ -0,0 +1,67 @@
|
||||
.content {
|
||||
/*display: flex;*/
|
||||
justify-content: center;
|
||||
padding: 3rem;
|
||||
}
|
||||
|
||||
.main {
|
||||
display: grid;
|
||||
grid-template-areas:
|
||||
"our_port search"
|
||||
"servers sites"
|
||||
"servers sites";
|
||||
grid-template-columns: 1fr 2fr;
|
||||
grid-template-rows: auto auto;
|
||||
}
|
||||
|
||||
.our_port {
|
||||
grid-area: our_port;
|
||||
background: #53f453;
|
||||
align-content: center;
|
||||
border-radius: 0.4rem;
|
||||
padding-left: 1rem;
|
||||
padding-right: 1rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.servers {
|
||||
grid-area: servers;
|
||||
}
|
||||
|
||||
.serv_elem {
|
||||
background: #fff454;
|
||||
align-content: center;
|
||||
border-radius: 0.4rem;
|
||||
padding-left: 1rem;
|
||||
min-height: 2.2rem;
|
||||
margin-top: 0.4rem;
|
||||
margin-right: 0.5rem;
|
||||
}
|
||||
|
||||
.sites {
|
||||
grid-area: sites;
|
||||
}
|
||||
|
||||
.sites_elem {
|
||||
background: #abd4f9;
|
||||
align-content: center;
|
||||
border-radius: 0.4rem;
|
||||
padding-left: 1rem;
|
||||
min-height: 2.2rem;
|
||||
margin-top: 0.4rem;
|
||||
}
|
||||
|
||||
.search {
|
||||
grid-area: search;
|
||||
}
|
||||
|
||||
|
||||
/* Действия при разрешении телефона */
|
||||
@media (max-width: 900px) {
|
||||
|
||||
.content {
|
||||
display: flex;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
}
|
5
config.json
Normal file
5
config.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"ports": [
|
||||
25128
|
||||
]
|
||||
}
|
81
interface.py
81
interface.py
@ -1,43 +1,60 @@
|
||||
import streamlit as st
|
||||
import streamlit.components.v1 as components
|
||||
from dash import Dash, dcc, html, Input, Output, callback
|
||||
app = Dash(__name__, title='Jetwork', update_title=None)
|
||||
|
||||
from os import walk
|
||||
from time import sleep
|
||||
from db import *
|
||||
from os import walk
|
||||
|
||||
# Получаем порт со входа
|
||||
from sys import argv
|
||||
our_port = argv[1]
|
||||
app.layout = html.Div([ html.Div([
|
||||
|
||||
html.Div([], id='our_port', className='our_port'),
|
||||
html.Div([], id='servers', className='servers'),
|
||||
html.Div([], id='sites', className='sites'),
|
||||
#dcc.Input(className='search', type='search', list=[1,2,3]),
|
||||
dcc.Dropdown(options=[], id='search', placeholder='Поиск...'),
|
||||
|
||||
dcc.Interval(id='interval-component', interval=1*1000, n_intervals=0)
|
||||
|
||||
], className='main')], className='content')
|
||||
|
||||
|
||||
st.title('jetwork')
|
||||
|
||||
ph = st.empty()
|
||||
# Обновление нашего порта (зачем?)
|
||||
@callback(Output('our_port', 'children'),
|
||||
Input('interval-component', 'n_intervals'))
|
||||
def update_our_port(n):
|
||||
return f"Ваш порт: {read()['our_port']}"
|
||||
|
||||
while True:
|
||||
# Боковая панель
|
||||
with ph.container():
|
||||
# Столбцы для элементов
|
||||
sidebar, space, main = st.columns([60, 10, 90])
|
||||
# Обновление доступных узлов
|
||||
@callback(Output('servers', 'children'),
|
||||
Input('interval-component', 'n_intervals'))
|
||||
def update_servers(n):
|
||||
res = []
|
||||
for i in read()['ports']:
|
||||
res.append(html.Div([i], className='serv_elem'))
|
||||
return res
|
||||
|
||||
# Обновление доступных сайтов
|
||||
@callback(Output('sites', 'children'),
|
||||
Input('interval-component', 'n_intervals'),
|
||||
Input('search', 'value'))
|
||||
def update_sites(n, s_val):
|
||||
# Если есть элемент в поиске
|
||||
if s_val:
|
||||
return html.Div([s_val], className='sites_elem')
|
||||
|
||||
with sidebar:
|
||||
st.success(f"Ваш порт: {our_port}")
|
||||
res = []
|
||||
for i in next(walk('cached/'), (None, None, []))[1]:
|
||||
res.append(html.Div([i], className='sites_elem'))
|
||||
return res
|
||||
|
||||
conf = read()
|
||||
if 'ports' in conf:
|
||||
ports = conf['ports']
|
||||
for i in ports:
|
||||
st.warning(f"{i}")
|
||||
# Обновление доступных сайтов в поиске
|
||||
@callback(Output('search', 'options'),
|
||||
Input('interval-component', 'n_intervals'))
|
||||
def update_search(n):
|
||||
res = []
|
||||
for i in next(walk('cached/'), (None, None, []))[1]:
|
||||
res.append(i)
|
||||
return res
|
||||
|
||||
with main:
|
||||
# Получаем все сайты
|
||||
sites = next(walk('cached/'), (None, None, []))[1]
|
||||
|
||||
for i in sites:
|
||||
addr = f"http://127.0.0.1:8000/{i}"
|
||||
st.info(f"[{i}]({addr})")
|
||||
|
||||
sleep(3)
|
||||
ph.empty()
|
||||
st.rerun()
|
||||
#app.run(debug=True, port = 5555)
|
||||
app.run(debug=False, port = 5555)
|
||||
|
29
main.py
29
main.py
@ -8,35 +8,41 @@ from network import *
|
||||
from updater import *
|
||||
from proxy import *
|
||||
from status import *
|
||||
from db import *
|
||||
|
||||
#
|
||||
# Здесь общий запуск всех файлов и команд
|
||||
|
||||
|
||||
#
|
||||
|
||||
def main():
|
||||
# Проверка обновлений
|
||||
from sys import argv
|
||||
if len(argv) == 1:
|
||||
print("Проверка обновлений...")
|
||||
system("git pull")
|
||||
print("Перезагрузка скрипта...")
|
||||
system("python main.py updated")
|
||||
print('Проверка обновлений...')
|
||||
system('git pull')
|
||||
print('Перезагрузка скрипта...')
|
||||
system('python main.py updated')
|
||||
exit()
|
||||
print("\nУспешно перезагружено!")
|
||||
print('\nУспешно перезагружено!')
|
||||
|
||||
# Запуск прокси для сервисов
|
||||
# проксируем http сервер
|
||||
http_port = port_gen()
|
||||
print(f"HTTP: {http_port}")
|
||||
print(f'HTTP: {http_port}')
|
||||
rp_http = Thread(target = watch_http, args=(http_port,))
|
||||
rp_http.start()
|
||||
|
||||
# проксируем сервер обработки запросов
|
||||
serv_port = port_gen()
|
||||
print(f"SERV: {serv_port}")
|
||||
print(f'SERV: {serv_port}')
|
||||
rp_serv = Thread(target = watch_serv, args=(serv_port,))
|
||||
rp_serv.start()
|
||||
|
||||
# Загружаем порт в конфиг
|
||||
conf = read()
|
||||
conf['our_port'] = serv_port
|
||||
write(conf)
|
||||
|
||||
# Стартуем сервисы
|
||||
# http сервер
|
||||
http = Thread(target = server_http)
|
||||
@ -49,11 +55,10 @@ def main():
|
||||
updater = Thread(target = update_demon, args=(serv_port,))
|
||||
updater.start()
|
||||
|
||||
# !!! ИДЁТ ПЕРЕРАБОТКА !!!
|
||||
# Стартуем интерфейс
|
||||
#system(f"python -m streamlit run --server.address=127.0.0.1 interface.py {serv_port}")
|
||||
system('python interface.py')
|
||||
|
||||
if __name__ == "__main__":
|
||||
if __name__ == '__main__':
|
||||
# Запускаем главный процесс, чтобы потом легко убить его
|
||||
p = Process(target=main)
|
||||
p.start()
|
||||
|
@ -36,9 +36,12 @@ def port_gen(st = 25000, end = 25200):
|
||||
return port
|
||||
|
||||
def server_http():
|
||||
while True:
|
||||
run = True
|
||||
while run == True:
|
||||
try:
|
||||
os.system("python -m http.server --directory cached")
|
||||
except KeyboardInterrupt:
|
||||
run = False
|
||||
except Exception as e:
|
||||
print("SERVER_HTTP FALLED")
|
||||
logging.critical(e, exc_info=True)
|
||||
@ -122,7 +125,7 @@ def recv(s, data_out):
|
||||
data_out.put(data)
|
||||
|
||||
# op = operation
|
||||
def client(port, op = "ping", host = 'jetwork.404.mn'):
|
||||
def client(port, op = "ping", host = 'bore.pub'):
|
||||
# Если порт не определён
|
||||
if not port:
|
||||
return None
|
||||
|
@ -2,15 +2,15 @@ from os import system, name
|
||||
from network import port_gen
|
||||
|
||||
port = input("Введите порт: ")
|
||||
dest = port_gen(7000, 9000)
|
||||
dest = port_gen(25300, 25500)
|
||||
|
||||
print(f"\nУдалённый ПОРТ: {dest}")
|
||||
print("\n[!] Не закрывайте это окно [!]\n")
|
||||
|
||||
if name == "posix":
|
||||
system(f"./bore local {port} --to jetwork.404.mn --port {dest}")
|
||||
system(f"./bore local {port} --to bore.pub --port {dest}")
|
||||
elif name == "nt":
|
||||
system(f"bore.exe local {port} --to jetwork.404.mn --port {dest}")
|
||||
system(f"bore.exe local {port} --to bore.pub --port {dest}")
|
||||
else:
|
||||
print("Увы, вероятно Ваша ОС не поддерживается.")
|
||||
print("Завершение работы...")
|
||||
|
@ -1,4 +1,4 @@
|
||||
cryptography
|
||||
requests
|
||||
tqdm
|
||||
streamlit
|
||||
dash
|
||||
|
28
setup.py
28
setup.py
@ -16,20 +16,20 @@ if name == "posix":
|
||||
import getpass
|
||||
user = getpass.getuser()
|
||||
|
||||
system("mkdir ~/.streamlit")
|
||||
with open(f"/home/{user}/.streamlit/credentials.toml", "w") as f:
|
||||
f.write('[general]\nemail = "a@a.a"')
|
||||
f.close()
|
||||
#system("mkdir ~/.streamlit")
|
||||
#with open(f"/home/{user}/.streamlit/credentials.toml", "w") as f:
|
||||
# f.write('[general]\nemail = "a@a.a"')
|
||||
#f.close()
|
||||
elif name == "nt":
|
||||
from shutil import unpack_archive as unpack
|
||||
download("https://github.com/ekzhang/bore/releases/download/v0.5.0/bore-v0.5.0-x86_64-pc-windows-msvc.zip", "bore.zip")
|
||||
unpack("bore.zip")
|
||||
system("del bore.zip")
|
||||
|
||||
system("mkdir C:\\Users\\windows\\.streamlit")
|
||||
with open("C:\\Users\\windows\\.streamlit\\credentials.toml", "w") as f:
|
||||
f.write('[general]\nemail = "a@a.a"')
|
||||
f.close()
|
||||
#system("mkdir C:\\Users\\windows\\.streamlit")
|
||||
#with open("C:\\Users\\windows\\.streamlit\\credentials.toml", "w") as f:
|
||||
# f.write('[general]\nemail = "a@a.a"')
|
||||
#f.close()
|
||||
else:
|
||||
print("Увы, вероятно Ваша ОС не поддерживается.")
|
||||
print("Завершение работы...")
|
||||
@ -40,12 +40,12 @@ system("mkdir cached")
|
||||
system("mkdir verify")
|
||||
system("mkdir mysites")
|
||||
|
||||
print("Максимальный размер для кэшированных файлов. (в гигабайтах)")
|
||||
print("Укажите 0 для отключения ограничения.")
|
||||
max = input(">> ")
|
||||
|
||||
# TODO
|
||||
#print("Максимальный размер для кэшированных файлов. (в гигабайтах)")
|
||||
#print("Укажите 0 для отключения ограничения.")
|
||||
#max = input(">> ")
|
||||
# Записываем в конфиг
|
||||
config["max"] = max
|
||||
write(config)
|
||||
#config["max"] = max
|
||||
#write(config)
|
||||
|
||||
print("\nЧтобы подключится к jetwork выполните: python main.py")
|
||||
|
81
srv_main.py
Normal file
81
srv_main.py
Normal file
@ -0,0 +1,81 @@
|
||||
from os import system, name
|
||||
from time import sleep
|
||||
|
||||
from threading import Thread
|
||||
from multiprocessing import Process
|
||||
|
||||
from network import *
|
||||
from updater import *
|
||||
from proxy import *
|
||||
from status import *
|
||||
from db import *
|
||||
|
||||
#
|
||||
# Здесь общий запуск всех файлов и команд
|
||||
#
|
||||
|
||||
def main():
|
||||
# Проверка обновлений
|
||||
from sys import argv
|
||||
if len(argv) == 1:
|
||||
print('Проверка обновлений...')
|
||||
system('git pull')
|
||||
print('Перезагрузка скрипта...')
|
||||
system('python main.py updated')
|
||||
exit()
|
||||
print('\nУспешно перезагружено!')
|
||||
|
||||
# Запуск прокси для сервисов
|
||||
# проксируем http сервер
|
||||
http_port = port_gen()
|
||||
print(f'HTTP: {http_port}')
|
||||
rp_http = Thread(target = watch_http, args=(http_port,))
|
||||
rp_http.start()
|
||||
|
||||
# проксируем сервер обработки запросов
|
||||
serv_port = port_gen()
|
||||
print(f'SERV: {serv_port}')
|
||||
rp_serv = Thread(target = watch_serv, args=(serv_port,))
|
||||
rp_serv.start()
|
||||
|
||||
# Загружаем порт в конфиг
|
||||
conf = read()
|
||||
conf['our_port'] = serv_port
|
||||
write(conf)
|
||||
|
||||
# Стартуем сервисы
|
||||
# http сервер
|
||||
http = Thread(target = server_http)
|
||||
http.start()
|
||||
# сервер обработки запросов
|
||||
srv = Thread(target = server, args=(http_port,))
|
||||
srv.start()
|
||||
|
||||
# Стартуем авто-поиск портов и авто-обновление сайтов
|
||||
#updater = Thread(target = update_demon, args=(serv_port,))
|
||||
#updater.start()
|
||||
|
||||
# Стартуем интерфейс
|
||||
system('python interface.py')
|
||||
|
||||
if __name__ == '__main__':
|
||||
# Запускаем главный процесс, чтобы потом легко убить его
|
||||
p = Process(target=main)
|
||||
p.start()
|
||||
|
||||
status_set(True) # Устанавливаем статус, что программа работает
|
||||
|
||||
st = status_check()
|
||||
while st:
|
||||
try:
|
||||
st = status_check()
|
||||
sleep(0.01)
|
||||
except KeyboardInterrupt:
|
||||
p.terminate()
|
||||
exit()
|
||||
except:
|
||||
pass
|
||||
|
||||
# Когда послан код завершения
|
||||
p.terminate()
|
||||
exit()
|
8
stop.py.save
Normal file
8
stop.py.save
Normal file
@ -0,0 +1,8 @@
|
||||
#
|
||||
# Установка/проверка статуса завершения
|
||||
#
|
||||
|
||||
import os
|
||||
|
||||
if not os.path.exists('status'):
|
||||
|
Loading…
Reference in New Issue
Block a user