mirror of
https://github.com/Justuser3310/jetwork.git
synced 2026-06-22 01:31:01 +00:00
Compare commits
24 Commits
9d2645d7ca
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 9ff83b0c0a | |||
| 59aeeaac33 | |||
| 6e96b0dfb3 | |||
| f06c6f963c | |||
| 1c4a7bb11a | |||
| dfd5d61db7 | |||
| d3a25ee190 | |||
| c5a0111fab | |||
| dfc37d6ea7 | |||
| e83bee6b08 | |||
| ca1e5422a2 | |||
| 54a4692cac | |||
| a44099a9e0 | |||
| b9aaef110f | |||
| 311cde3b15 | |||
| b6652cf5d6 | |||
| 2abe6dfb87 | |||
| 5cec15dbd5 | |||
| 6ce7dbc771 | |||
| 89e34cd473 | |||
| 27eba1fbf4 | |||
| f89269a1f6 | |||
| ce628c40d6 | |||
| f09daea63e |
@@ -2,19 +2,19 @@ import os
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
if not os.path.exists('config.json'):
|
if not os.path.exists('config.json'):
|
||||||
db = {"os": None,"our_port": 0000, "ports": [], "domain": "http://0.0.0.0:8000"}
|
db = {'os': None,'our_port': 0000, 'ports': [], 'base_url': 'http://0.0.0.0:8000'}
|
||||||
js = json.dumps(db, indent=2)
|
js = json.dumps(db, indent=2)
|
||||||
with open("config.json", "w") as outfile:
|
with open('config.json', 'w') as outfile:
|
||||||
outfile.write(js)
|
outfile.write(js)
|
||||||
print('Created new config.json')
|
print('Created new config.json')
|
||||||
|
|
||||||
|
|
||||||
def read(file = 'config.json'):
|
def read(file = 'config.json'):
|
||||||
with open(file, "r", encoding="utf-8") as openfile:
|
with open(file, 'r', encoding='utf-8') as openfile:
|
||||||
db = json.load(openfile)
|
db = json.load(openfile)
|
||||||
return db
|
return db
|
||||||
|
|
||||||
def write(db, file = 'config.json'):
|
def write(db, file = 'config.json'):
|
||||||
js = json.dumps(db, indent=2, ensure_ascii=False)
|
js = json.dumps(db, indent=2, ensure_ascii=False)
|
||||||
with open(file, "w", encoding="utf-8") as outfile:
|
with open(file, 'w', encoding='utf-8') as outfile:
|
||||||
outfile.write(js)
|
outfile.write(js)
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{"activeProfileId":"InternalProfile_SmartRules","defaultProxyServerId":"usundlzx4uvk2","firstEverInstallNotified":true,"options":{"syncSettings":false,"syncActiveProfile":true,"syncActiveProxy":true,"detectRequestFailures":true,"displayFailedOnBadge":true,"displayAppliedProxyOnBadge":true,"displayMatchedRuleOnBadge":true,"refreshTabOnConfigChanges":false,"proxyPerOrigin":true,"enableShortcuts":true,"shortcutNotification":true,"themeType":0,"themesDark":"themes-cosmo-dark"},"product":"SmartProxy","proxyProfiles":[{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileId":"InternalProfile_Direct","profileType":0,"profileTypeConfig":{"builtin":true,"editable":false,"selectable":true,"supportsSubscriptions":false,"supportsProfileProxy":false,"customProxyPerRule":false,"canBeDisabled":false,"supportsRuleActionWhitelist":false,"defaultRuleActionIsWhitelist":null},"profileName":"Direct (No Proxy)","profileProxyServerId":null},{"enabled":true,"proxyRules":[{"enabled":true,"whiteList":false,"ruleId":99411781,"autoGeneratePattern":true,"ruleType":0,"hostName":"jet","rulePattern":"*.jet/*","ruleRegex":"","ruleExact":"","proxy":{"name":"jet_local","id":"ezgallzykftxq","order":1,"host":"127.0.0.1","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},"proxyServerId":"ezgallzykftxq"},{"enabled":true,"whiteList":false,"ruleId":274078801725,"autoGeneratePattern":true,"ruleType":0,"hostName":"mirror","rulePattern":"*.mirror/*","ruleRegex":"","ruleExact":"","proxy":{"name":"jet_local","id":"ezgallzykftxq","order":1,"host":"127.0.0.1","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},"proxyServerId":"ezgallzykftxq"},{"enabled":true,"whiteList":false,"ruleId":597907496,"autoGeneratePattern":true,"ruleType":0,"hostName":"me","rulePattern":"*.me/*","ruleRegex":"","ruleExact":"","proxy":{"name":"jet_local","id":"ezgallzykftxq","order":1,"host":"127.0.0.1","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},"proxyServerId":"ezgallzykftxq"}],"rulesSubscriptions":[],"profileId":"InternalProfile_SmartRules","profileType":2,"profileTypeConfig":{"builtin":true,"editable":true,"selectable":true,"supportsSubscriptions":true,"supportsProfileProxy":true,"customProxyPerRule":true,"canBeDisabled":true,"supportsRuleActionWhitelist":true,"defaultRuleActionIsWhitelist":false},"profileName":"Smart Proxy","profileProxyServerId":""},{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileId":"InternalProfile_AlwaysEnabled","profileType":3,"profileTypeConfig":{"builtin":true,"editable":true,"selectable":true,"supportsSubscriptions":true,"supportsProfileProxy":true,"customProxyPerRule":true,"canBeDisabled":true,"supportsRuleActionWhitelist":true,"defaultRuleActionIsWhitelist":true},"profileName":"Always Enable","profileProxyServerId":null},{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileId":"InternalProfile_SystemProxy","profileType":1,"profileTypeConfig":{"builtin":true,"editable":false,"selectable":true,"supportsSubscriptions":false,"supportsProfileProxy":false,"customProxyPerRule":false,"canBeDisabled":false,"supportsRuleActionWhitelist":false,"defaultRuleActionIsWhitelist":null},"profileName":"System Proxy","profileProxyServerId":null},{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileType":4,"profileTypeConfig":{"builtin":true,"editable":false,"selectable":false,"supportsSubscriptions":false,"supportsProfileProxy":false,"customProxyPerRule":false,"canBeDisabled":false,"supportsRuleActionWhitelist":false,"defaultRuleActionIsWhitelist":null},"profileName":"Ignore Failure Rules","profileId":"profile-ms5zflzx4opc8"}],"proxyServerSubscriptions":[],"proxyServers":[{"name":"jet_public","id":"usundlzx4uvk2","order":3,"host":"jet.del.pw","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},{"name":"jet_local","id":"ezgallzykftxq","order":1,"host":"127.0.0.1","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null}],"updateInfo":{"updateIsAvailable":false,"downloadPage":null,"version":null,"versionName":null,"isBrowserSpecific":true},"version":"1.5"}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
{"activeProfileId":"InternalProfile_SmartRules","defaultProxyServerId":"usundlzx4uvk2","firstEverInstallNotified":true,"options":{"syncSettings":false,"syncActiveProfile":true,"syncActiveProxy":true,"detectRequestFailures":true,"displayFailedOnBadge":true,"displayAppliedProxyOnBadge":true,"displayMatchedRuleOnBadge":true,"refreshTabOnConfigChanges":false,"proxyPerOrigin":true,"enableShortcuts":true,"shortcutNotification":true,"themeType":0,"themesDark":"themes-cosmo-dark"},"product":"SmartProxy","proxyProfiles":[{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileId":"InternalProfile_Direct","profileType":0,"profileTypeConfig":{"builtin":true,"editable":false,"selectable":true,"supportsSubscriptions":false,"supportsProfileProxy":false,"customProxyPerRule":false,"canBeDisabled":false,"supportsRuleActionWhitelist":false,"defaultRuleActionIsWhitelist":null},"profileName":"Direct (No Proxy)","profileProxyServerId":null},{"enabled":true,"proxyRules":[{"enabled":true,"whiteList":false,"ruleId":42142459831829816,"autoGeneratePattern":true,"ruleType":0,"hostName":"jet","rulePattern":"*.jet/*","ruleRegex":"","ruleExact":"","proxy":{"name":"jet_public","id":"usundlzx4uvk2","order":3,"host":"jet.del.pw","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},"proxyServerId":"usundlzx4uvk2"},{"enabled":true,"whiteList":false,"ruleId":995421339685,"autoGeneratePattern":true,"ruleType":0,"hostName":"mirror","rulePattern":"*.mirror/*","ruleRegex":"","ruleExact":"","proxy":{"name":"jet_public","id":"usundlzx4uvk2","order":3,"host":"jet.del.pw","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},"proxyServerId":"usundlzx4uvk2"},{"enabled":true,"whiteList":false,"ruleId":7021094,"autoGeneratePattern":true,"ruleType":0,"hostName":"me","rulePattern":"*.me/*","ruleRegex":"","ruleExact":"","proxy":{"name":"jet_public","id":"usundlzx4uvk2","order":3,"host":"jet.del.pw","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},"proxyServerId":"usundlzx4uvk2"}],"rulesSubscriptions":[],"profileId":"InternalProfile_SmartRules","profileType":2,"profileTypeConfig":{"builtin":true,"editable":true,"selectable":true,"supportsSubscriptions":true,"supportsProfileProxy":true,"customProxyPerRule":true,"canBeDisabled":true,"supportsRuleActionWhitelist":true,"defaultRuleActionIsWhitelist":false},"profileName":"Smart Proxy","profileProxyServerId":""},{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileId":"InternalProfile_AlwaysEnabled","profileType":3,"profileTypeConfig":{"builtin":true,"editable":true,"selectable":true,"supportsSubscriptions":true,"supportsProfileProxy":true,"customProxyPerRule":true,"canBeDisabled":true,"supportsRuleActionWhitelist":true,"defaultRuleActionIsWhitelist":true},"profileName":"Always Enable","profileProxyServerId":null},{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileId":"InternalProfile_SystemProxy","profileType":1,"profileTypeConfig":{"builtin":true,"editable":false,"selectable":true,"supportsSubscriptions":false,"supportsProfileProxy":false,"customProxyPerRule":false,"canBeDisabled":false,"supportsRuleActionWhitelist":false,"defaultRuleActionIsWhitelist":null},"profileName":"System Proxy","profileProxyServerId":null},{"enabled":true,"proxyRules":[],"rulesSubscriptions":[],"profileType":4,"profileTypeConfig":{"builtin":true,"editable":false,"selectable":false,"supportsSubscriptions":false,"supportsProfileProxy":false,"customProxyPerRule":false,"canBeDisabled":false,"supportsRuleActionWhitelist":false,"defaultRuleActionIsWhitelist":null},"profileName":"Ignore Failure Rules","profileId":"profile-ms5zflzx4opc8"}],"proxyServerSubscriptions":[],"proxyServers":[{"name":"jet_public","id":"usundlzx4uvk2","order":3,"host":"jet.del.pw","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null},{"name":"jet_local","id":"ezgallzykftxq","order":1,"host":"127.0.0.1","port":"8080","protocol":"HTTP","username":"","password":"","proxyDNS":true,"failoverTimeout":null}],"updateInfo":{"updateIsAvailable":false,"downloadPage":null,"version":null,"versionName":null,"isBrowserSpecific":true},"version":"1.5"}
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
from re import compile, sub
|
from re import compile, sub
|
||||||
domains = ['jet', 'mirror', 'org', 'info', 'news', 'me']
|
domains = ['jet', 'mirror', 'me']
|
||||||
|
|
||||||
def domain_ok(domain):
|
def domain_ok(domain):
|
||||||
global domains
|
global domains
|
||||||
|
|||||||
+5
-9
@@ -67,21 +67,17 @@ def update_servers(n):
|
|||||||
Input('interval-component', 'n_intervals'),
|
Input('interval-component', 'n_intervals'),
|
||||||
Input('search', 'value'))
|
Input('search', 'value'))
|
||||||
def update_sites(n, s_val):
|
def update_sites(n, s_val):
|
||||||
# Домен по умолчанию
|
# Префикс
|
||||||
domain = read()['domain']
|
base_url = read()['base_url']
|
||||||
# Если есть элемент в поиске
|
# Если есть элемент в поиске
|
||||||
if s_val:
|
if s_val:
|
||||||
return html.Div([ dcc.Link(children=i, href=f'{domain}/{s_val}',
|
return html.Div([ dcc.Link(children=i, href=f'{base_url}/{s_val}',
|
||||||
target='_blank') ], className='sites_elem')
|
target='_blank') ], className='sites_elem')
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for i in next(walk('cached/'), (None, None, []))[1]:
|
for i in next(walk('cached/'), (None, None, []))[1]:
|
||||||
conf = read(f'cached/{i}/config.json')
|
conf = read(f'cached/{i}/config.json')
|
||||||
if conf['type'] == 'dynamic':
|
res.append(html.Div([ dcc.Link(children=i, href=f'http://{i}',
|
||||||
res.append(html.Div([ dcc.Link(children=i, href=f'http://bore.pub:{conf["port"]}',
|
|
||||||
target='_blank') ], className='sites_elem'))
|
|
||||||
else:
|
|
||||||
res.append(html.Div([ dcc.Link(children=i, href=f'{domain}/{i}',
|
|
||||||
target='_blank') ], className='sites_elem'))
|
target='_blank') ], className='sites_elem'))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -95,4 +91,4 @@ def update_search(n):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
#app.run(debug=True, port = 5555)
|
#app.run(debug=True, port = 5555)
|
||||||
app.run(debug=False, port = 5555)
|
app.run(debug=False, host = '0.0.0.0', port = 5555)
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ from multiprocessing import Process
|
|||||||
from network import *
|
from network import *
|
||||||
from updater import *
|
from updater import *
|
||||||
from proxy import *
|
from proxy import *
|
||||||
|
from web_proxy import *
|
||||||
from status import *
|
from status import *
|
||||||
|
|
||||||
from db import *
|
from db import *
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -47,9 +49,12 @@ def main():
|
|||||||
# http сервер
|
# http сервер
|
||||||
http = Thread(target = server_http)
|
http = Thread(target = server_http)
|
||||||
http.start()
|
http.start()
|
||||||
# сервер обработки запросов
|
# Cервер обработки запросов
|
||||||
srv = Thread(target = server, args=(http_port,))
|
srv = Thread(target = server, args=(http_port,))
|
||||||
srv.start()
|
srv.start()
|
||||||
|
# Прокси для браузера
|
||||||
|
http_proxy = Thread(target = web_proxy)
|
||||||
|
http_proxy.start()
|
||||||
|
|
||||||
# Стартуем авто-поиск портов и авто-обновление сайтов
|
# Стартуем авто-поиск портов и авто-обновление сайтов
|
||||||
updater = Thread(target = update_demon, args=(serv_port,))
|
updater = Thread(target = update_demon, args=(serv_port,))
|
||||||
|
|||||||
+18
-12
@@ -13,6 +13,9 @@ from db import read
|
|||||||
from json import loads
|
from json import loads
|
||||||
# Логирование ошибок
|
# Логирование ошибок
|
||||||
import logging
|
import logging
|
||||||
|
# Просто логирование
|
||||||
|
from icecream import ic
|
||||||
|
ic.disable() # Отключение логирования
|
||||||
|
|
||||||
from verify import *
|
from verify import *
|
||||||
from domain_check import *
|
from domain_check import *
|
||||||
@@ -43,7 +46,7 @@ def server_http():
|
|||||||
except KeyboardInterrupt:
|
except KeyboardInterrupt:
|
||||||
run = False
|
run = False
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("SERVER_HTTP FALLED")
|
ic("SERVER_HTTP FALLED")
|
||||||
logging.critical(e, exc_info=True)
|
logging.critical(e, exc_info=True)
|
||||||
|
|
||||||
def server(http_port):
|
def server(http_port):
|
||||||
@@ -59,7 +62,7 @@ def server(http_port):
|
|||||||
s.listen(2)
|
s.listen(2)
|
||||||
conn, address = s.accept()
|
conn, address = s.accept()
|
||||||
|
|
||||||
print("Connection from: " + str(address))
|
ic("Connection from: " + str(address))
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
@@ -104,7 +107,7 @@ def server(http_port):
|
|||||||
conn.close()
|
conn.close()
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("SERVER_HTTP FALLED")
|
ic("SERVER_HTTP FALLED")
|
||||||
logging.critical(e, exc_info=True)
|
logging.critical(e, exc_info=True)
|
||||||
|
|
||||||
|
|
||||||
@@ -120,11 +123,11 @@ def recv(s, data_out):
|
|||||||
okay = True
|
okay = True
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
print(data)
|
ic(data)
|
||||||
data_out.put(data)
|
data_out.put(data)
|
||||||
|
|
||||||
# op = operation
|
# op = operation
|
||||||
def client(port, op = "ping", host = 'bore.pub'):
|
def client(port, op = "ping", host = 'bore.del.pw'):
|
||||||
# Если порт не определён
|
# Если порт не определён
|
||||||
if not port:
|
if not port:
|
||||||
return None
|
return None
|
||||||
@@ -173,8 +176,11 @@ def client(port, op = "ping", host = 'bore.pub'):
|
|||||||
return "old"
|
return "old"
|
||||||
|
|
||||||
# Скачиваем файлы
|
# Скачиваем файлы
|
||||||
g_site = get(f"http://{host}:{str(port)}/{site}.zip")
|
try:
|
||||||
print('SIZE: ', g_site.headers['Content-Length']) # Размер
|
g_site = get(f"http://{host}:{str(port)}/{site}.zip")
|
||||||
|
except:
|
||||||
|
return 'error'
|
||||||
|
ic('SIZE: ', g_site.headers['Content-Length']) # Размер
|
||||||
|
|
||||||
with open(f"verify/{site}.zip", "wb") as f:
|
with open(f"verify/{site}.zip", "wb") as f:
|
||||||
f.write(g_site.content)
|
f.write(g_site.content)
|
||||||
@@ -211,10 +217,10 @@ def client(port, op = "ping", host = 'bore.pub'):
|
|||||||
our_ver = our_conf["ver"]
|
our_ver = our_conf["ver"]
|
||||||
# Если версия не новее - злоумышленник
|
# Если версия не новее - злоумышленник
|
||||||
if our_ver >= dest_ver:
|
if our_ver >= dest_ver:
|
||||||
print("[!] Обнаружена подмена версии сайта.")
|
ic("[!] Обнаружена подмена версии сайта.")
|
||||||
# Сохраняем ключ злоумышленника
|
# Сохраняем ключ злоумышленника
|
||||||
os.replace(f"verify/{site}.pem", f"verify/{site}.pem.FAKE")
|
os.replace(f"verify/{site}.pem", f"verify/{site}.pem.FAKE")
|
||||||
print(f"[!] Порт злоумышленника: {port}")
|
ic(f"[!] Порт злоумышленника: {port}")
|
||||||
# Удаляем фальшивые файлы
|
# Удаляем фальшивые файлы
|
||||||
os.remove(f"verify/{site}.zip")
|
os.remove(f"verify/{site}.zip")
|
||||||
os.remove(f"verify/{site}.sig")
|
os.remove(f"verify/{site}.sig")
|
||||||
@@ -232,11 +238,11 @@ def client(port, op = "ping", host = 'bore.pub'):
|
|||||||
copytree(f"verify/{site}", f"cached/{site}")
|
copytree(f"verify/{site}", f"cached/{site}")
|
||||||
rmtree(f"verify/{site}")
|
rmtree(f"verify/{site}")
|
||||||
else:
|
else:
|
||||||
print("[!] Обнаружена подмена сайта.")
|
ic("[!] Обнаружена подмена сайта.")
|
||||||
# Сохраняем ключ злоумышленника
|
# Сохраняем ключ злоумышленника
|
||||||
os.replace(f"verify/{site}.pem", f"verify/{site}.pem.FAKE")
|
os.replace(f"verify/{site}.pem", f"verify/{site}.pem.FAKE")
|
||||||
print(f"[!] Порт злоумышленника: {port}")
|
ic(f"[!] Порт злоумышленника: {port}")
|
||||||
print(f"[!] Ключ (вероятно) злоумышленника сохранён в verify/{site}.pem.FAKE\n")
|
ic(f"[!] Ключ (вероятно) злоумышленника сохранён в verify/{site}.pem.FAKE\n")
|
||||||
# Удаляем фальшивые файлы
|
# Удаляем фальшивые файлы
|
||||||
os.remove(f"verify/{site}.zip")
|
os.remove(f"verify/{site}.zip")
|
||||||
os.remove(f"verify/{site}.sig")
|
os.remove(f"verify/{site}.sig")
|
||||||
|
|||||||
@@ -10,18 +10,18 @@ def proxy_http(port):
|
|||||||
global http_out
|
global http_out
|
||||||
os = read()['os']
|
os = read()['os']
|
||||||
if os == 'Linux':
|
if os == 'Linux':
|
||||||
http_out = system(f'./bore local 8000 --to bore.pub --port {port}')
|
http_out = system(f'./bore local 8000 --to bore.del.pw --port {port}')
|
||||||
elif os == 'Windows' or os == 'Android':
|
elif os == 'Windows' or os == 'Android':
|
||||||
http_out = system(f'bore local 8000 --to bore.pub --port {port}')
|
http_out = system(f'bore local 8000 --to bore.del.pw --port {port}')
|
||||||
|
|
||||||
global serv_out ; serv_out = None
|
global serv_out ; serv_out = None
|
||||||
def proxy_serv(port):
|
def proxy_serv(port):
|
||||||
global serv_out
|
global serv_out
|
||||||
os = read()['os']
|
os = read()['os']
|
||||||
if os == 'Linux':
|
if os == 'Linux':
|
||||||
http_out = system(f'./bore local 8001 --to bore.pub --port {port}')
|
http_out = system(f'./bore local 8001 --to bore.del.pw --port {port}')
|
||||||
elif os == 'Windows' or os == 'Android':
|
elif os == 'Windows' or os == 'Android':
|
||||||
http_out = system(f'bore local 8001 --to bore.pub --port {port}')
|
http_out = system(f'bore local 8001 --to bore.del.pw --port {port}')
|
||||||
|
|
||||||
|
|
||||||
def watch_http(port):
|
def watch_http(port):
|
||||||
|
|||||||
@@ -2,3 +2,4 @@ cryptography
|
|||||||
requests
|
requests
|
||||||
tqdm
|
tqdm
|
||||||
dash
|
dash
|
||||||
|
icecream
|
||||||
|
|||||||
@@ -15,8 +15,14 @@ conf = read()
|
|||||||
conf['os'] = os
|
conf['os'] = os
|
||||||
write(conf)
|
write(conf)
|
||||||
|
|
||||||
|
if os == 'Android':
|
||||||
print('''---
|
print('''---
|
||||||
[1/3] Устанавливаем зависимости python...
|
Устанавливаем зависимости rust...
|
||||||
|
---''')
|
||||||
|
system('pkg install rust')
|
||||||
|
|
||||||
|
print('''---
|
||||||
|
[1/3] Устанавливаем зависимости Python...
|
||||||
---''')
|
---''')
|
||||||
system('pip install -r requirements.txt')
|
system('pip install -r requirements.txt')
|
||||||
|
|
||||||
@@ -33,7 +39,7 @@ elif os == 'Windows':
|
|||||||
unpack('bore.zip')
|
unpack('bore.zip')
|
||||||
system('del bore.zip')
|
system('del bore.zip')
|
||||||
elif os == 'Android':
|
elif os == 'Android':
|
||||||
system('pkg install bore-cli')
|
system('pkg install bore')
|
||||||
else:
|
else:
|
||||||
print('Увы, вероятно Ваша ОС не поддерживается.')
|
print('Увы, вероятно Ваша ОС не поддерживается.')
|
||||||
print('Завершение работы...')
|
print('Завершение работы...')
|
||||||
|
|||||||
+2
-3
@@ -134,7 +134,7 @@ elif op == '4':
|
|||||||
client(port, f'publish_{domain}<>{http_port}')
|
client(port, f'publish_{domain}<>{http_port}')
|
||||||
sleep(5)
|
sleep(5)
|
||||||
|
|
||||||
host = 'bore.pub'
|
host = 'bore.del.pw'
|
||||||
# Проверяем тип сайта
|
# Проверяем тип сайта
|
||||||
type = read(f'mysites//{domain}/config.json')['type']
|
type = read(f'mysites//{domain}/config.json')['type']
|
||||||
# Если динамический - вставляем спец страницу
|
# Если динамический - вставляем спец страницу
|
||||||
@@ -163,8 +163,7 @@ if op != '':
|
|||||||
if pub == 'n':
|
if pub == 'n':
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
print('Введите ваш порт сервера (при запуске main.py)')
|
serv_port = int( read()['our_port'] )
|
||||||
serv_port = int(input('>> '))
|
|
||||||
http_port = client(serv_port, f'is_{domain}')
|
http_port = client(serv_port, f'is_{domain}')
|
||||||
|
|
||||||
print('Получаем все порты...')
|
print('Получаем все порты...')
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
while true
|
||||||
|
do
|
||||||
|
killall python
|
||||||
|
sleep 1s
|
||||||
|
killall python #Чтоб наверняка
|
||||||
|
sleep 60s # Ждём, чтобы не было ошибки при перезапуске "данный порт уже используется"
|
||||||
|
|
||||||
|
nohup python srv_main.py &
|
||||||
|
sleep 6h
|
||||||
|
done
|
||||||
+5
-9
@@ -52,21 +52,17 @@ def update_servers(n):
|
|||||||
Input('interval-component', 'n_intervals'),
|
Input('interval-component', 'n_intervals'),
|
||||||
Input('search', 'value'))
|
Input('search', 'value'))
|
||||||
def update_sites(n, s_val):
|
def update_sites(n, s_val):
|
||||||
# Домен по умолчанию
|
# Префикс
|
||||||
domain = read()['domain']
|
base_url = read()['base_url']
|
||||||
# Если есть элемент в поиске
|
# Если есть элемент в поиске
|
||||||
if s_val:
|
if s_val:
|
||||||
return html.Div([ dcc.Link(children=i, href=f'{domain}/{s_val}',
|
return html.Div([ dcc.Link(children=i, href=f'{base_url}/{s_val}',
|
||||||
target='_blank') ], className='sites_elem')
|
target='_blank') ], className='sites_elem')
|
||||||
|
|
||||||
res = []
|
res = []
|
||||||
for i in next(walk('cached/'), (None, None, []))[1]:
|
for i in next(walk('cached/'), (None, None, []))[1]:
|
||||||
conf = read(f'cached/{i}/config.json')
|
conf = read(f'cached/{i}/config.json')
|
||||||
if conf['type'] == 'dynamic':
|
res.append(html.Div([ dcc.Link(children=i, href=f'http://{i}',
|
||||||
res.append(html.Div([ dcc.Link(children=i, href=f'http://bore.pub:{conf["port"]}',
|
|
||||||
target='_blank') ], className='sites_elem'))
|
|
||||||
else:
|
|
||||||
res.append(html.Div([ dcc.Link(children=i, href=f'{domain}/{i}',
|
|
||||||
target='_blank') ], className='sites_elem'))
|
target='_blank') ], className='sites_elem'))
|
||||||
return res
|
return res
|
||||||
|
|
||||||
@@ -80,4 +76,4 @@ def update_search(n):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
#app.run(debug=True, port = 5555)
|
#app.run(debug=True, port = 5555)
|
||||||
app.run(debug=False, port = 5555)
|
app.run(debug=False, host = '0.0.0.0', port = 5555)
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ from multiprocessing import Process
|
|||||||
from network import *
|
from network import *
|
||||||
from updater import *
|
from updater import *
|
||||||
from proxy import *
|
from proxy import *
|
||||||
|
from web_proxy import *
|
||||||
from status import *
|
from status import *
|
||||||
|
|
||||||
from db import *
|
from db import *
|
||||||
|
|
||||||
#
|
#
|
||||||
@@ -55,6 +57,10 @@ def main():
|
|||||||
#updater = Thread(target = update_demon, args=(serv_port,))
|
#updater = Thread(target = update_demon, args=(serv_port,))
|
||||||
#updater.start()
|
#updater.start()
|
||||||
|
|
||||||
|
# Прокси для браузера
|
||||||
|
http_proxy = Thread(target = web_proxy)
|
||||||
|
http_proxy.start()
|
||||||
|
|
||||||
# Стартуем интерфейс
|
# Стартуем интерфейс
|
||||||
system('python srv_interface.py')
|
system('python srv_interface.py')
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
killall ./srv.sh
|
||||||
|
killall python
|
||||||
|
killall bore
|
||||||
+7
-4
@@ -6,6 +6,9 @@ from network import *
|
|||||||
|
|
||||||
# Логирование ошибок
|
# Логирование ошибок
|
||||||
import logging
|
import logging
|
||||||
|
# Просто логирование
|
||||||
|
from icecream import ic
|
||||||
|
ic.disable() # Отключение логирования
|
||||||
|
|
||||||
def update_demon(serv_port):
|
def update_demon(serv_port):
|
||||||
while True:
|
while True:
|
||||||
@@ -40,23 +43,23 @@ def update_demon(serv_port):
|
|||||||
if check[0] == el:
|
if check[0] == el:
|
||||||
# Сверяем версии
|
# Сверяем версии
|
||||||
if check[1] >= ver:
|
if check[1] >= ver:
|
||||||
print("Ver_ok: ", el)
|
ic("Ver_ok: ", el)
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
# Если версия новее
|
# Если версия новее
|
||||||
print("Ver_new: ", el)
|
ic("Ver_new: ", el)
|
||||||
http_port = client(port, f"is_{el}")
|
http_port = client(port, f"is_{el}")
|
||||||
client(http_port, f"get_{el}")
|
client(http_port, f"get_{el}")
|
||||||
found = True
|
found = True
|
||||||
break # Если нашли - выходим
|
break # Если нашли - выходим
|
||||||
|
|
||||||
if not found:
|
if not found:
|
||||||
print("Not_found: ", el)
|
ic("Not_found: ", el)
|
||||||
http_port = client(port, f"is_{el}")
|
http_port = client(port, f"is_{el}")
|
||||||
client(http_port, f"get_{el}")
|
client(http_port, f"get_{el}")
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print("UPDATER FALLED")
|
ic("UPDATER FALLED")
|
||||||
logging.critical(e, exc_info=True)
|
logging.critical(e, exc_info=True)
|
||||||
|
|||||||
@@ -0,0 +1,82 @@
|
|||||||
|
import http.server
|
||||||
|
import socketserver
|
||||||
|
import urllib.request
|
||||||
|
import logging
|
||||||
|
from os.path import exists
|
||||||
|
|
||||||
|
from db import *
|
||||||
|
base_url = read()['base_url']
|
||||||
|
|
||||||
|
# Логирование
|
||||||
|
from icecream import ic
|
||||||
|
ic.disable() # Выключить отладку
|
||||||
|
|
||||||
|
class Proxy(http.server.SimpleHTTPRequestHandler):
|
||||||
|
# Отключение всех сообщений (чтобы не забивать вывод)
|
||||||
|
def log_message(self, format, *args):
|
||||||
|
pass
|
||||||
|
def do_GET(self):
|
||||||
|
ic(f"Request for: {self.path}")
|
||||||
|
|
||||||
|
# 'js-check.jet/favicon.ico' -> '127.0.0.1:8000/favicon.ico'
|
||||||
|
target = self.path
|
||||||
|
domain = target[7:]
|
||||||
|
domain = domain[:domain.find('/')]
|
||||||
|
|
||||||
|
if not exists(f'cached/{domain}'):
|
||||||
|
self.send_error(404, f"Site not found")
|
||||||
|
return 404
|
||||||
|
|
||||||
|
# Если статичный
|
||||||
|
if read(f'cached/{domain}/config.json')['type'] == 'static':
|
||||||
|
target = f'{base_url}/{target[7:]}' # http://127.0.0.1:8000 / js-check.jet
|
||||||
|
# Если динамический
|
||||||
|
elif read(f'cached/{domain}/config.json')['type'] == 'dynamic':
|
||||||
|
port = read(f'cached/{domain}/config.json')['port']
|
||||||
|
target = f'http://bore.del.pw:{port}/{target.replace(f"http://{domain}/", "")}'
|
||||||
|
|
||||||
|
ic(f"Modded request: {target}")
|
||||||
|
|
||||||
|
# Направление запроса по адресу
|
||||||
|
try:
|
||||||
|
with urllib.request.urlopen(target) as response:
|
||||||
|
self.send_response(response.getcode())
|
||||||
|
self.send_header("Content-type", response.headers.get_content_type())
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(response.read())
|
||||||
|
except Exception as e:
|
||||||
|
self.send_error(500, f"Error: {str(e)}")
|
||||||
|
|
||||||
|
def do_POST(self):
|
||||||
|
ic(f"Request for: {self.path}")
|
||||||
|
|
||||||
|
if not exists(f'cached/{domain}'):
|
||||||
|
self.send_error(404, f"Site not found")
|
||||||
|
return 404
|
||||||
|
|
||||||
|
if read(f'cached/{domain}/config.json')['type'] == 'static':
|
||||||
|
target = f'{base_url}/{target[7:]}' # http://127.0.0.1:8000 / js-check.jet
|
||||||
|
elif read(f'cached/{domain}/config.json')['type'] == 'dynamic':
|
||||||
|
port = read(f'cached/{domain}/config.json')['port']
|
||||||
|
target = f'http://bore.del.pw:{port}/{target.replace(f"http://{domain}/", "")}'
|
||||||
|
|
||||||
|
ic(f"Modded request: {target}")
|
||||||
|
|
||||||
|
# Направление запроса по адресу
|
||||||
|
try:
|
||||||
|
content_length = int(self.headers['Content-Length'])
|
||||||
|
post_data = self.rfile.read(content_length)
|
||||||
|
req = urllib.request.Request(self.path, data=post_data, method='POST')
|
||||||
|
with urllib.request.urlopen(req) as response:
|
||||||
|
self.send_response(response.getcode())
|
||||||
|
self.send_header("Content-type", response.headers.get_content_type())
|
||||||
|
self.end_headers()
|
||||||
|
self.wfile.write(response.read())
|
||||||
|
except Exception as e:
|
||||||
|
self.send_error(500, f"Error: {str(e)}")
|
||||||
|
|
||||||
|
def web_proxy():
|
||||||
|
PORT = 8080
|
||||||
|
with socketserver.TCPServer(("", PORT), Proxy) as httpd:
|
||||||
|
print(f"HTTP proxy on port {PORT}")
|
||||||
|
httpd.serve_forever()
|
||||||
Reference in New Issue
Block a user