jack 6 ماه پیش
والد
کامیت
ad9c4d9e60
3فایلهای تغییر یافته به همراه0 افزوده شده و 114 حذف شده
  1. 0 20
      Dockerfile
  2. 0 15
      docker-compose.yaml
  3. 0 79
      main.py

+ 0 - 20
Dockerfile

@@ -1,20 +0,0 @@
-# 使用 Python 3.11 作为基础镜像
-FROM python:3.11-slim
-
-# 设置工作目录
-WORKDIR /app
-
-# 复制项目文件
-COPY main.py .
-
-# 安装依赖
-RUN pip install nicegui
-
-# 暴露端口
-EXPOSE 48345
-
-# 设置环境变量
-ENV PYTHONUNBUFFERED=1
-
-# 运行应用
-CMD ["python", "main.py"]

+ 0 - 15
docker-compose.yaml

@@ -1,15 +0,0 @@
-version: '3.8'
-
-services:
-  clash-tools:
-    image: clash-tools:latest
-    build:
-      context: .
-      dockerfile: Dockerfile
-    ports:
-      - "48345:48345"
-    volumes:
-      - ./:/app
-    environment:
-      - PYTHONUNBUFFERED=1
-    restart: always

+ 0 - 79
main.py

@@ -1,79 +0,0 @@
-from nicegui import ui
-import httpx
-
-async def check_now_node(url_and_port):
-    url = f"http://{url_and_port}"
-    key = "/api/configs"
-    full_url = url + key
-
-    data = {"mode": "Global"}
-    headers = {"Content-Type": "application/json"}
-
-    async with httpx.AsyncClient() as client:
-        try:
-            response = await client.patch(full_url, json=data, headers=headers)
-            if response.status_code != 204:
-                raise Exception(f"请求失败: {response.status_code}")
-        except httpx.HTTPError as exc:
-            print(f"请求失败: {exc}")
-            return None
-
-        url_proxies = f"http://{url_and_port}/api/proxies"
-        headers_proxies = {
-            # 这里可以复用之前的headers
-            "Accept": "application/json, text/plain, */*",
-            "Host": url_and_port,
-            # 其他可按需设置
-        }
-
-        try:
-            response = await client.get(url_proxies, headers=headers_proxies)
-            json_data = response.json()
-            if not json_data or response.status_code != 200:
-                print("JSON data is empty or request failed")
-                return None
-
-            proxies = json_data.get("proxies")
-            proxy_global = proxies.get("GLOBAL")
-            now_proxy = proxy_global.get("now")
-
-            return now_proxy
-        except httpx.RequestError as e:
-            print(f"Request failed: {e}")
-            return None
-
-async def handle_check_now_node():
-    ip = '192.168.31.201'
-    port_list = ['58001', '58002', '58003', '58004', '58005', '58006', '58007', '58008', '58009', '58010']
-    results = []
-
-    for port in port_list:
-        url_and_port = f"{ip}:{port}"
-        now_proxy = await check_now_node(url_and_port)
-        results.append(f"{url_and_port}: \t{now_proxy}")
-
-    msg = "\n".join(results)
-    print(msg)
-
-    dialog = ui.dialog()
-    with dialog:
-        ui.label(msg).classes("whitespace-pre-wrap text-left")
-
-    dialog.props("max-width=700px")
-    dialog.open()
-
-def handle_switch_node():
-    print("Switch IP button clicked")
-
-def main():
-    with ui.row().classes("mx-auto"):
-        ui.button("Check Now Node", on_click=handle_check_now_node).classes("mt-1")
-        ui.button("Switch Node", on_click=handle_switch_node).classes("mt-1")
-
-        ui.label("Filter Node").classes("text-lg font-bold text-blue-500 mt-4")
-        ui.input(value="JP").classes("w-96")
-
-    ui.run(port=48345)
-
-if __name__ in {"__main__", "__mp_main__"}:
-    main()