mirror of
				https://github.com/Justuser3310/jetwork.git
				synced 2025-10-31 18:41:07 +00:00 
			
		
		
		
	Compare commits
	
		
			13 Commits
		
	
	
		
			9d2645d7ca
			...
			54a4692cac
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
|  | 54a4692cac | ||
|  | a44099a9e0 | ||
|  | b9aaef110f | ||
|  | 311cde3b15 | ||
|  | b6652cf5d6 | ||
|  | 2abe6dfb87 | ||
|  | 5cec15dbd5 | ||
|  | 6ce7dbc771 | ||
|  | 89e34cd473 | ||
|  | 27eba1fbf4 | ||
|  | f89269a1f6 | ||
|  | ce628c40d6 | ||
|  | f09daea63e | 
| @ -1,5 +1,5 @@ | |||||||
| from re import compile, sub | from re import compile, sub | ||||||
| domains = ['jet', 'mirror', 'org', 'info', 'news', 'me'] | domains = ['jet', 'dyn'] | ||||||
| 
 | 
 | ||||||
| def domain_ok(domain): | def domain_ok(domain): | ||||||
| 	global domains | 	global domains | ||||||
|  | |||||||
| @ -77,11 +77,7 @@ def update_sites(n, s_val): | |||||||
| 	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
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.py
									
									
									
									
									
								
							| @ -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,)) | ||||||
|  | |||||||
| @ -124,7 +124,7 @@ def recv(s, data_out): | |||||||
| 	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,7 +173,10 @@ def client(port, op = "ping", host = 'bore.pub'): | |||||||
| 				return "old" | 				return "old" | ||||||
| 
 | 
 | ||||||
| 		# Скачиваем файлы | 		# Скачиваем файлы | ||||||
| 		g_site = get(f"http://{host}:{str(port)}/{site}.zip") | 		try: | ||||||
|  | 			g_site = get(f"http://{host}:{str(port)}/{site}.zip") | ||||||
|  | 		except: | ||||||
|  | 			return 'error' | ||||||
| 		print('SIZE: ', g_site.headers['Content-Length']) # Размер | 		print('SIZE: ', g_site.headers['Content-Length']) # Размер | ||||||
| 
 | 
 | ||||||
| 		with open(f"verify/{site}.zip", "wb") as f: | 		with open(f"verify/{site}.zip", "wb") as f: | ||||||
|  | |||||||
							
								
								
									
										8
									
								
								proxy.py
									
									
									
									
									
								
							
							
						
						
									
										8
									
								
								proxy.py
									
									
									
									
									
								
							| @ -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 | ||||||
|  | |||||||
| @ -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('Получаем все порты...') | ||||||
|  | |||||||
							
								
								
									
										9
									
								
								srv.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										9
									
								
								srv.sh
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,9 @@ | |||||||
|  | while true | ||||||
|  | do | ||||||
|  | killall python | ||||||
|  | sleep 2s | ||||||
|  | killall python #Чтоб наверняка | ||||||
|  | 
 | ||||||
|  | nohup python srv_main.py & | ||||||
|  | sleep 6h | ||||||
|  | done | ||||||
| @ -62,11 +62,7 @@ def update_sites(n, s_val): | |||||||
| 	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') | ||||||
| 
 | 
 | ||||||
|  | |||||||
							
								
								
									
										69
									
								
								web_proxy.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										69
									
								
								web_proxy.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,69 @@ | |||||||
|  | import http.server | ||||||
|  | import socketserver | ||||||
|  | import urllib.request | ||||||
|  | import logging | ||||||
|  | 
 | ||||||
|  | from db import * | ||||||
|  | domain = read()['domain'] | ||||||
|  | 
 | ||||||
|  | # Логирование | ||||||
|  | #logging.basicConfig(level=ic, format='%(asctime)s - %(message)s') | ||||||
|  | from icecream import ic | ||||||
|  | ic.disable() # Выключить отладку | ||||||
|  | 
 | ||||||
|  | class Proxy(http.server.SimpleHTTPRequestHandler): | ||||||
|  | 	def do_GET(self): | ||||||
|  | 		# Log the requested domain | ||||||
|  | 		ic(f"Request for: {self.path}") | ||||||
|  | 
 | ||||||
|  | 		# 'js-check.jet/favicon.ico' -> '127.0.0.1:8000/favicon.ico' | ||||||
|  | 		target = self.path | ||||||
|  | 		# Если статичный | ||||||
|  | 		if 'jet' in target: | ||||||
|  | 			target = f'{domain}/{target[7:]}' # http://127.0.0.1:8000 / js-check.jet | ||||||
|  | 			ic(f"Modded request: {target}") | ||||||
|  | 		elif 'dyn' in target: | ||||||
|  | 			addr = target[target.find('://')+3:] | ||||||
|  | 			addr = addr[:addr.find('/')] | ||||||
|  | 			port = read(f'cached/{addr}/config.json')['port'] | ||||||
|  | 			target = f'http://bore.del.pw:{port}/{target[target.find("dyn")+4:]}' | ||||||
|  | 			ic(f"Modded request: {target}") | ||||||
|  | 
 | ||||||
|  | 		# Forward the request to the actual server | ||||||
|  | 		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): | ||||||
|  | 		# Log the requested domain | ||||||
|  | 		ic(f"Request for: {self.path}") | ||||||
|  | 
 | ||||||
|  | 		if 'jet' in target: | ||||||
|  | 			target = f'{domain}/{target[7:]}' # http://127.0.0.1:8000 / js-check.jet | ||||||
|  | 			ic(f"Modded request: {target}") | ||||||
|  | 		else: | ||||||
|  | 			pass | ||||||
|  | 
 | ||||||
|  | 		# Forward the request to the actual server | ||||||
|  | 		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: | ||||||
|  | 		ic(f"Serving on port {PORT}") | ||||||
|  | 		httpd.serve_forever() | ||||||
							
								
								
									
										71
									
								
								web_proxy.py.bak
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								web_proxy.py.bak
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,71 @@ | |||||||
|  | import http.server | ||||||
|  | import socketserver | ||||||
|  | import urllib.request | ||||||
|  | import logging | ||||||
|  | 
 | ||||||
|  | from db import * | ||||||
|  | domain = read()['domain'] | ||||||
|  | 
 | ||||||
|  | # Логирование | ||||||
|  | #logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(message)s') | ||||||
|  | from icecream import ic | ||||||
|  | 
 | ||||||
|  | class Proxy(http.server.SimpleHTTPRequestHandler): | ||||||
|  | 	def do_GET(self): | ||||||
|  | 		# Log the requested domain | ||||||
|  | 		logging.info(f"Request for: {self.path}") | ||||||
|  | 
 | ||||||
|  | 		# 'js-check.jet/favicon.ico' -> '127.0.0.1:8000/favicon.ico' | ||||||
|  | 		target = self.path | ||||||
|  | 		# Если статичный | ||||||
|  | 		if 'jet' in target: | ||||||
|  | 			target = f'{domain}/{target[7:]}' # http://127.0.0.1:8000 / js-check.jet | ||||||
|  | 			logging.info(f"Modded request: {target}") | ||||||
|  | 		elif 'dyn' in target: | ||||||
|  | 			addr = target[target.find('://')+3:] | ||||||
|  | 			addr = addr[:addr.find('/')] | ||||||
|  | 			port = read(f'cached/{addr}/config.json')['port'] | ||||||
|  | 			target = f'http://bore.pub:{port}/{target[target.find("dyn")+4:]}' | ||||||
|  | 			logging.info(f"Modded request: {target}") | ||||||
|  | 
 | ||||||
|  | 		# Forward the request to the actual server | ||||||
|  | 		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): | ||||||
|  | 		# Log the requested domain | ||||||
|  | 		logging.info(f"Request for: {self.path}") | ||||||
|  | 
 | ||||||
|  | 		if 'jet' in target: | ||||||
|  | 			target = f'{domain}/{target[7:]}' # http://127.0.0.1:8000 / js-check.jet | ||||||
|  | 			logging.info(f"Modded request: {target}") | ||||||
|  | 		else: | ||||||
|  | 			pass | ||||||
|  | 
 | ||||||
|  | 		# Forward the request to the actual server | ||||||
|  | 		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)}") | ||||||
|  | 
 | ||||||
|  | #if __name__ == "__main__": | ||||||
|  | def web_proxy(): | ||||||
|  | 	PORT = 8080 | ||||||
|  | 	with socketserver.TCPServer(("", PORT), Proxy) as httpd: | ||||||
|  | 		logging.info(f"Serving on port {PORT}") | ||||||
|  | 		httpd.serve_forever() | ||||||
|  | 
 | ||||||
|  | web_proxy() | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user