通信傍受を抽象表示しなかったのを戻した
This commit is contained in:
parent
942f632891
commit
ea0ced9214
1 changed files with 11 additions and 15 deletions
26
oproxy.py
26
oproxy.py
|
|
@ -93,7 +93,6 @@ async def analyze_models():
|
|||
models_data = res.json().get("models", [])
|
||||
total = len(models_data)
|
||||
enriched = []
|
||||
|
||||
for i, m in enumerate(models_data, 1):
|
||||
full_name = m["name"]
|
||||
draw_progress(i, total, full_name.split("/")[-1])
|
||||
|
|
@ -116,7 +115,6 @@ async def analyze_models():
|
|||
|
||||
print("\n")
|
||||
enriched.sort(key=lambda x: (x["score"], x["display_name"], -x["size_gb"]))
|
||||
|
||||
print(
|
||||
f"{get_ts()} {C_GREEN}--- リモートモデル戦力分析 (Target: {url}) ---{C_RESET}"
|
||||
)
|
||||
|
|
@ -137,7 +135,6 @@ async def analyze_models():
|
|||
else f"{C_GRAY}[----]{C_RESET}"
|
||||
)
|
||||
name, size = em["display_name"], f"{em['size_gb']:>5.1f} GiB"
|
||||
|
||||
if get_visual_width(name) > NAME_MAX_WIDTH:
|
||||
print(f"{get_ts()} {status} {tool} {name[:NAME_MAX_WIDTH]} {size}")
|
||||
print(
|
||||
|
|
@ -147,7 +144,6 @@ async def analyze_models():
|
|||
print(
|
||||
f"{get_ts()} {status} {tool} {pad_right(name, NAME_MAX_WIDTH)} {size}"
|
||||
)
|
||||
|
||||
print(f"{get_ts()} {C_GREEN}{'-' * 80}{C_RESET}")
|
||||
show_help()
|
||||
except Exception as e:
|
||||
|
|
@ -166,11 +162,14 @@ def show_help():
|
|||
async def sticky_proxy(path: str, request: Request):
|
||||
target_url = f"{CONFIG['url']}/{path}"
|
||||
|
||||
# --- 修正箇所: SyntaxError を防ぐため完全に複数行に展開 ---
|
||||
# 1. リクエスト吸い込みの可視化
|
||||
print(f"\n{get_ts()} /{path} -> {CONFIG['url']}: ", end="", flush=True)
|
||||
body = b""
|
||||
async for chunk in request.stream():
|
||||
body += chunk
|
||||
# ------------------------------------------------------
|
||||
print(f"{C_CYAN}^{C_RESET}", end="", flush=True)
|
||||
|
||||
print(f"{C_YELLOW}|{C_RESET}", end="", flush=True)
|
||||
|
||||
headers = {
|
||||
k: v
|
||||
|
|
@ -184,8 +183,12 @@ async def sticky_proxy(path: str, request: Request):
|
|||
async with client.stream(
|
||||
request.method, target_url, content=body, headers=headers
|
||||
) as response:
|
||||
# 2. レスポンス吐き出しの可視化
|
||||
print(f"{C_GREEN}v:{C_RESET}", end="", flush=True)
|
||||
async for chunk in response.aiter_bytes():
|
||||
print(f"{C_GREEN}v{C_RESET}", end="", flush=True)
|
||||
yield chunk
|
||||
print(f"{C_YELLOW}*{C_RESET}", end="", flush=True)
|
||||
except Exception as e:
|
||||
print(f" {C_RED}[Err] {e}{C_RESET}")
|
||||
|
||||
|
|
@ -198,7 +201,6 @@ def interactive_shell():
|
|||
line = sys.stdin.readline().strip().lower()
|
||||
if not line:
|
||||
continue
|
||||
|
||||
if line == "q":
|
||||
os._exit(0)
|
||||
elif line == "?":
|
||||
|
|
@ -210,13 +212,9 @@ def interactive_shell():
|
|||
CONFIG["url"] = f"http://127.0.0.1:{new_port}"
|
||||
threading.Thread(target=run_analyze, daemon=True).start()
|
||||
else:
|
||||
print(
|
||||
f"{C_RED}ポート番号を指定してください (例: :p 11435){C_RESET}"
|
||||
)
|
||||
print(f"{C_RED}ポート指定ミス: :p 11435{C_RESET}")
|
||||
else:
|
||||
print(
|
||||
f"{C_GRAY}未知のコマンドです: '{line}' ( ? でヘルプ表示 ){C_RESET}"
|
||||
)
|
||||
print(f"{C_GRAY}未知のコマンド: '{line}'{C_RESET}")
|
||||
except EOFError:
|
||||
break
|
||||
|
||||
|
|
@ -227,9 +225,7 @@ def main():
|
|||
parser.add_argument("-l", "--local", type=int, default=11434)
|
||||
args = parser.parse_args()
|
||||
CONFIG["url"] = f"http://127.0.0.1:{args.remote}"
|
||||
|
||||
asyncio.run(analyze_models())
|
||||
|
||||
threading.Thread(target=interactive_shell, daemon=True).start()
|
||||
uvicorn.run(app, host="127.0.0.1", port=args.local, log_level="error")
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue