2024-06-21 13:40:31 +00:00
|
|
|
from os import system
|
2024-02-26 09:34:32 +00:00
|
|
|
from threading import Thread
|
2024-02-25 19:53:01 +00:00
|
|
|
from time import sleep
|
|
|
|
|
2024-06-19 20:18:13 +00:00
|
|
|
from status import *
|
2024-06-21 13:44:39 +00:00
|
|
|
from db import read
|
2024-06-19 20:18:13 +00:00
|
|
|
|
2024-02-25 19:53:01 +00:00
|
|
|
global http_out ; http_out = None
|
|
|
|
def proxy_http(port):
|
|
|
|
global http_out
|
2024-06-21 13:40:31 +00:00
|
|
|
os = read()['os']
|
|
|
|
if os == 'Linux':
|
|
|
|
http_out = system(f'./bore local 8000 --to bore.pub --port {port}')
|
|
|
|
elif os == 'Windows' or os == 'Android':
|
|
|
|
http_out = system(f'bore local 8000 --to bore.pub --port {port}')
|
2024-02-25 19:53:01 +00:00
|
|
|
|
|
|
|
global serv_out ; serv_out = None
|
|
|
|
def proxy_serv(port):
|
|
|
|
global serv_out
|
2024-06-21 13:40:31 +00:00
|
|
|
os = read()['os']
|
|
|
|
if os == 'Linux':
|
|
|
|
http_out = system(f'./bore local 8001 --to bore.pub --port {port}')
|
|
|
|
elif os == 'Windows' or os == 'Android':
|
|
|
|
http_out = system(f'bore local 8001 --to bore.pub --port {port}')
|
2024-02-25 19:53:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
def watch_http(port):
|
2024-02-26 09:34:32 +00:00
|
|
|
run = Thread(target=proxy_http, args=(port,))
|
2024-02-25 19:53:01 +00:00
|
|
|
run.start()
|
|
|
|
|
|
|
|
global http_out
|
2024-06-19 20:18:13 +00:00
|
|
|
st = status_check()
|
|
|
|
while st:
|
2024-02-25 19:53:01 +00:00
|
|
|
# Если команда вышла
|
2024-02-26 09:34:32 +00:00
|
|
|
if http_out or not run.is_alive():
|
|
|
|
run.join(1)
|
2024-02-25 19:53:01 +00:00
|
|
|
http_out = None
|
2024-02-26 09:34:32 +00:00
|
|
|
run = Thread(target=proxy_http, args=(port,))
|
2024-02-25 19:53:01 +00:00
|
|
|
run.start()
|
2024-06-19 20:18:13 +00:00
|
|
|
st = status_check()
|
2024-02-25 19:53:01 +00:00
|
|
|
sleep(1)
|
|
|
|
|
|
|
|
def watch_serv(port):
|
2024-02-26 09:34:32 +00:00
|
|
|
run = Thread(target=proxy_serv, args=(port,))
|
2024-02-25 19:53:01 +00:00
|
|
|
run.start()
|
|
|
|
|
|
|
|
global serv_out
|
2024-06-19 20:18:13 +00:00
|
|
|
st = status_check()
|
|
|
|
while st:
|
2024-02-26 09:34:32 +00:00
|
|
|
if serv_out or not run.is_alive():
|
|
|
|
run.join(1)
|
2024-02-25 19:53:01 +00:00
|
|
|
serv_out = None
|
2024-02-26 09:34:32 +00:00
|
|
|
run = Thread(target=proxy_serv, args=(port,))
|
2024-02-25 19:53:01 +00:00
|
|
|
run.start()
|
2024-06-19 20:18:13 +00:00
|
|
|
st = status_check()
|
2024-02-25 19:53:01 +00:00
|
|
|
sleep(1)
|