Nokia123543 commited on
Commit
ca67dec
·
verified ·
1 Parent(s): 079bd34

PLUS: пульс с первого байта против 520 и логи прокси в файл

Browse files
Files changed (1) hide show
  1. plus/serve_muscriptor.py +19 -1
plus/serve_muscriptor.py CHANGED
@@ -421,7 +421,7 @@ def start_proxy(server_port: int, listen_port: int,
421
  "--listen", str(listen_port), "--target", str(server_port),
422
  "--instruments", instruments]
423
  + (["--multi-pass", multi_pass] if multi_pass else []),
424
- stdout=subprocess.DEVNULL, stderr=subprocess.STDOUT)
425
  for _ in range(20):
426
  time.sleep(0.5)
427
  if proc.poll() is not None:
@@ -530,6 +530,7 @@ def main(argv: list[str] | None = None) -> int:
530
  say(">>> OPEN THIS LINK: " + str(tunnel.url))
531
 
532
  started, beat = time.time(), time.time()
 
533
  try:
534
  while True:
535
  time.sleep(10)
@@ -548,6 +549,23 @@ def main(argv: list[str] | None = None) -> int:
548
  say("прокси упал, поднимаю заново")
549
  proxy = start_proxy(args.port, proxy_port, args.instruments,
550
  args.multi_pass, args.no_articulation)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
551
  if tunnel is not None and not tunnel.alive():
552
  say("туннель умер, открываю новый")
553
  tunnel.kill()
 
421
  "--listen", str(listen_port), "--target", str(server_port),
422
  "--instruments", instruments]
423
  + (["--multi-pass", multi_pass] if multi_pass else []),
424
+ stdout=open("muscriptor_proxy.log", "a"), stderr=subprocess.STDOUT)
425
  for _ in range(20):
426
  time.sleep(0.5)
427
  if proc.poll() is not None:
 
530
  say(">>> OPEN THIS LINK: " + str(tunnel.url))
531
 
532
  started, beat = time.time(), time.time()
533
+ public_fails, checked = 0, time.time()
534
  try:
535
  while True:
536
  time.sleep(10)
 
549
  say("прокси упал, поднимаю заново")
550
  proxy = start_proxy(args.port, proxy_port, args.instruments,
551
  args.multi_pass, args.no_articulation)
552
+ if tunnel is not None and tunnel.url and time.time() - checked > 60:
553
+ checked = time.time()
554
+ status, body = probe_page(tunnel.url)
555
+ fine, note = looks_like_app(status, body)
556
+ if fine:
557
+ public_fails = 0
558
+ else:
559
+ public_fails += 1
560
+ say(" ссылка снаружи: %s (%d подряд)" % (note, public_fails))
561
+ if public_fails >= 2:
562
+ say(" переоткрываю туннель: снаружи не отвечает")
563
+ tunnel.kill()
564
+ tunnel = open_tunnel(proxy_port, order)
565
+ write_link(tunnel.url or "", args.port, proxy_port)
566
+ if tunnel.url:
567
+ say(">>> OPEN THIS LINK: " + tunnel.url)
568
+ public_fails = 0
569
  if tunnel is not None and not tunnel.alive():
570
  say("туннель умер, открываю новый")
571
  tunnel.kill()