mirror of
				https://github.com/Justuser3310/jetwork.git
				synced 2025-10-30 18:12:17 +00:00 
			
		
		
		
	Compare commits
	
		
			No commits in common. "54a4692cac00ed0f6657227cdf3d81db18f60fa3" and "9d2645d7cab85b179845d7dfbe1973737a778c87" have entirely different histories.
		
	
	
		
			54a4692cac
			...
			9d2645d7ca
		
	
		
| @ -1,5 +1,5 @@ | |||||||
| from re import compile, sub | from re import compile, sub | ||||||
| domains = ['jet', 'dyn'] | domains = ['jet', 'mirror', 'org', 'info', 'news', 'me'] | ||||||
| 
 | 
 | ||||||
| def domain_ok(domain): | def domain_ok(domain): | ||||||
| 	global domains | 	global domains | ||||||
|  | |||||||
| @ -77,7 +77,11 @@ 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') | ||||||
| 		res.append(html.Div([ dcc.Link(children=i, href=f'http://{i}', | 		if conf['type'] == 'dynamic': | ||||||
|  | 			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 | ||||||
| 
 | 
 | ||||||
| @ -91,4 +95,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, host = '0.0.0.0', port = 5555) | app.run(debug=False, port = 5555) | ||||||
|  | |||||||
							
								
								
									
										7
									
								
								main.py
									
									
									
									
									
								
							
							
						
						
									
										7
									
								
								main.py
									
									
									
									
									
								
							| @ -7,9 +7,7 @@ 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 * | ||||||
| 
 | 
 | ||||||
| # | # | ||||||
| @ -49,12 +47,9 @@ 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.del.pw'): | def client(port, op = "ping", host = 'bore.pub'): | ||||||
| 	# Если порт не определён | 	# Если порт не определён | ||||||
| 	if not port: | 	if not port: | ||||||
| 		return None | 		return None | ||||||
| @ -173,10 +173,7 @@ def client(port, op = "ping", host = 'bore.del.pw'): | |||||||
| 				return "old" | 				return "old" | ||||||
| 
 | 
 | ||||||
| 		# Скачиваем файлы | 		# Скачиваем файлы | ||||||
| 		try: | 		g_site = get(f"http://{host}:{str(port)}/{site}.zip") | ||||||
| 			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.del.pw --port {port}') | 		http_out = system(f'./bore local 8000 --to bore.pub --port {port}') | ||||||
| 	elif os == 'Windows' or os == 'Android': | 	elif os == 'Windows' or os == 'Android': | ||||||
| 		http_out = system(f'bore local 8000 --to bore.del.pw --port {port}') | 		http_out = system(f'bore local 8000 --to bore.pub --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.del.pw --port {port}') | 		http_out = system(f'./bore local 8001 --to bore.pub --port {port}') | ||||||
| 	elif os == 'Windows' or os == 'Android': | 	elif os == 'Windows' or os == 'Android': | ||||||
| 	  http_out = system(f'bore local 8001 --to bore.del.pw --port {port}') | 	  http_out = system(f'bore local 8001 --to bore.pub --port {port}') | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def watch_http(port): | def watch_http(port): | ||||||
|  | |||||||
| @ -2,4 +2,3 @@ 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.del.pw' | host = 'bore.pub' | ||||||
| # Проверяем тип сайта | # Проверяем тип сайта | ||||||
| type = read(f'mysites//{domain}/config.json')['type'] | type = read(f'mysites//{domain}/config.json')['type'] | ||||||
| # Если динамический - вставляем спец страницу | # Если динамический - вставляем спец страницу | ||||||
| @ -163,7 +163,8 @@ if op != '': | |||||||
| if pub == 'n': | if pub == 'n': | ||||||
| 	exit() | 	exit() | ||||||
| 
 | 
 | ||||||
| serv_port = int( read()['our_port'] ) | print('Введите ваш порт сервера (при запуске main.py)') | ||||||
|  | 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
									
									
									
									
									
								
							
							
						
						
									
										9
									
								
								srv.sh
									
									
									
									
									
								
							| @ -1,9 +0,0 @@ | |||||||
| while true |  | ||||||
| do |  | ||||||
| killall python |  | ||||||
| sleep 2s |  | ||||||
| killall python #Чтоб наверняка |  | ||||||
| 
 |  | ||||||
| nohup python srv_main.py & |  | ||||||
| sleep 6h |  | ||||||
| done |  | ||||||
| @ -62,7 +62,11 @@ 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') | ||||||
| 		res.append(html.Div([ dcc.Link(children=i, href=f'http://{i}', | 		if conf['type'] == 'dynamic': | ||||||
|  | 			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 | ||||||
| 
 | 
 | ||||||
| @ -76,4 +80,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, host = '0.0.0.0', port = 5555) | app.run(debug=False, port = 5555) | ||||||
|  | |||||||
| @ -7,9 +7,7 @@ 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 * | ||||||
| 
 | 
 | ||||||
| # | # | ||||||
| @ -57,10 +55,6 @@ 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
									
									
									
									
									
								
							
							
						
						
									
										69
									
								
								web_proxy.py
									
									
									
									
									
								
							| @ -1,69 +0,0 @@ | |||||||
| 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() |  | ||||||
| @ -1,71 +0,0 @@ | |||||||
| 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