usmo 0.8.2__tar.gz → 0.8.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. {usmo-0.8.2 → usmo-0.8.3}/PKG-INFO +1 -1
  2. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/clash.md +8 -2
  3. {usmo-0.8.2 → usmo-0.8.3}/scripts/_config.json +2 -2
  4. {usmo-0.8.2 → usmo-0.8.3}/scripts/clash.py +51 -15
  5. {usmo-0.8.2 → usmo-0.8.3}/src/usmo/_version.py +2 -2
  6. {usmo-0.8.2 → usmo-0.8.3}/.github/workflows/docs.yml +0 -0
  7. {usmo-0.8.2 → usmo-0.8.3}/.github/workflows/release.yml +0 -0
  8. {usmo-0.8.2 → usmo-0.8.3}/.gitignore +0 -0
  9. {usmo-0.8.2 → usmo-0.8.3}/.pre-commit-config.yaml +0 -0
  10. {usmo-0.8.2 → usmo-0.8.3}/README.md +0 -0
  11. {usmo-0.8.2 → usmo-0.8.3}/dev/bump_version.py +0 -0
  12. {usmo-0.8.2 → usmo-0.8.3}/docs/architecture.md +0 -0
  13. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/bench.md +0 -0
  14. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/blobmount.md +0 -0
  15. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/builtin.md +0 -0
  16. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/clip.md +0 -0
  17. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/cp.md +0 -0
  18. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/cu122.md +0 -0
  19. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/gpu.md +0 -0
  20. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/index.md +0 -0
  21. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/init.md +0 -0
  22. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/inject-alias.md +0 -0
  23. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/notify.md +0 -0
  24. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/openai-proxy.md +0 -0
  25. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/port.md +0 -0
  26. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/proxy.md +0 -0
  27. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/rsync.md +0 -0
  28. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/secret.md +0 -0
  29. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/serve.md +0 -0
  30. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/share.md +0 -0
  31. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/sysinfo.md +0 -0
  32. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/tunnel.md +0 -0
  33. {usmo-0.8.2 → usmo-0.8.3}/docs/commands/wait.md +0 -0
  34. {usmo-0.8.2 → usmo-0.8.3}/docs/development.md +0 -0
  35. {usmo-0.8.2 → usmo-0.8.3}/docs/index.md +0 -0
  36. {usmo-0.8.2 → usmo-0.8.3}/docs/installation.md +0 -0
  37. {usmo-0.8.2 → usmo-0.8.3}/mkdocs.yml +0 -0
  38. {usmo-0.8.2 → usmo-0.8.3}/pyproject.toml +0 -0
  39. {usmo-0.8.2 → usmo-0.8.3}/scripts/bench.py +0 -0
  40. {usmo-0.8.2 → usmo-0.8.3}/scripts/blobmount.sh +0 -0
  41. {usmo-0.8.2 → usmo-0.8.3}/scripts/check_py.sh +0 -0
  42. {usmo-0.8.2 → usmo-0.8.3}/scripts/clip.py +0 -0
  43. {usmo-0.8.2 → usmo-0.8.3}/scripts/cp.py +0 -0
  44. {usmo-0.8.2 → usmo-0.8.3}/scripts/cu122.sh +0 -0
  45. {usmo-0.8.2 → usmo-0.8.3}/scripts/gpu.py +0 -0
  46. {usmo-0.8.2 → usmo-0.8.3}/scripts/init.sh +0 -0
  47. {usmo-0.8.2 → usmo-0.8.3}/scripts/inject_alias.py +0 -0
  48. {usmo-0.8.2 → usmo-0.8.3}/scripts/install.sh +0 -0
  49. {usmo-0.8.2 → usmo-0.8.3}/scripts/notify.py +0 -0
  50. {usmo-0.8.2 → usmo-0.8.3}/scripts/openai_proxy.py +0 -0
  51. {usmo-0.8.2 → usmo-0.8.3}/scripts/port.py +0 -0
  52. {usmo-0.8.2 → usmo-0.8.3}/scripts/proxy.py +0 -0
  53. {usmo-0.8.2 → usmo-0.8.3}/scripts/rsync.py +0 -0
  54. {usmo-0.8.2 → usmo-0.8.3}/scripts/secret.py +0 -0
  55. {usmo-0.8.2 → usmo-0.8.3}/scripts/serve.py +0 -0
  56. {usmo-0.8.2 → usmo-0.8.3}/scripts/share.py +0 -0
  57. {usmo-0.8.2 → usmo-0.8.3}/scripts/sysinfo.sh +0 -0
  58. {usmo-0.8.2 → usmo-0.8.3}/scripts/tunnel.py +0 -0
  59. {usmo-0.8.2 → usmo-0.8.3}/scripts/wait.py +0 -0
  60. {usmo-0.8.2 → usmo-0.8.3}/src/usmo/__init__.py +0 -0
  61. {usmo-0.8.2 → usmo-0.8.3}/src/usmo/cli.py +0 -0
  62. {usmo-0.8.2 → usmo-0.8.3}/src/usmo/core.py +0 -0
  63. {usmo-0.8.2 → usmo-0.8.3}/tests/conftest.py +0 -0
  64. {usmo-0.8.2 → usmo-0.8.3}/tests/test_core_alias.py +0 -0
  65. {usmo-0.8.2 → usmo-0.8.3}/tests/test_core_autocheck.py +0 -0
  66. {usmo-0.8.2 → usmo-0.8.3}/tests/test_core_hash.py +0 -0
  67. {usmo-0.8.2 → usmo-0.8.3}/tests/test_core_script.py +0 -0
  68. {usmo-0.8.2 → usmo-0.8.3}/tests/test_openai_proxy.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: usmo
3
- Version: 0.8.2
3
+ Version: 0.8.3
4
4
  Summary: Bootstrap machines and run cached utility scripts from one CLI.
5
5
  Project-URL: Homepage, https://github.com/HSPK/usm
6
6
  Project-URL: Repository, https://github.com/HSPK/usm
@@ -46,7 +46,7 @@ manager overrides (port/mode/tun)─┘ │
46
46
  | `tun on\|off\|status` | Toggle TUN (transparent system-wide capture). |
47
47
  | `lan on\|off\|status` | Toggle `allow-lan` (let other devices use this box). |
48
48
  | `port [N]` | Get or set the local mixed HTTP+SOCKS port. |
49
- | `logs [-f] [-n N] [--level L]` | Tail the log file, or stream live via the API. |
49
+ | `logs [-f\|-w] [-n N] [--level L]` | Tail the log file, or stream live via the API. |
50
50
  | `conns [-w] [--close]` | Show active connections; `-w` watches live. |
51
51
  | `dash [--no-open]` | Open the local web dashboard (metacubexd, served by mihomo). |
52
52
  | `enable` / `disable` | Autostart at login via a systemd `--user` unit. |
@@ -227,7 +227,7 @@ source ~/.cache/usm/clash/proxy.env # http_proxy/https_proxy/all_proxy
227
227
 
228
228
  ```bash
229
229
  usm clash logs -n 100 # tail the log file
230
- usm clash logs -f # stream live logs via the API (Ctrl-C to stop)
230
+ usm clash logs -f # stream live logs via the API (-w also works)
231
231
  usm clash conns # active connections (host, chain, rule, up/down)
232
232
  usm clash conns -w # watch them live (full-screen; Ctrl-C to stop)
233
233
  usm clash conns --close # drop all connections
@@ -240,6 +240,12 @@ hosted site. The first `dash` (or `setup`) downloads the dashboard (~1 MB) into
240
240
  `~/.cache/usm/clash/ui`; `dash` then opens the URL (with host/port/secret
241
241
  pre-filled) in your browser, or just prints it with `--no-open`.
242
242
 
243
+ !!! note "First `dash` restarts the core"
244
+ mihomo only mounts the `external-ui` server at startup, so if the core was
245
+ already running before the dashboard was installed, `dash` restarts it once
246
+ to start serving `/ui/`. After that the dashboard stays available (it's
247
+ served by the core itself), and `usm clash status` shows its URL.
248
+
243
249
  ## State & files
244
250
 
245
251
  Everything lives under `~/.cache/usm/clash/`:
@@ -196,8 +196,8 @@
196
196
  "requests>=2.32.4",
197
197
  "rich>=13.0"
198
198
  ],
199
- "version": "1.0.14",
200
- "hash": "sha256:8dc319dfcdfd997e64e1f2be1c8809b52f78086e4e4534a03e9b116f0ae95689"
199
+ "version": "1.0.15",
200
+ "hash": "sha256:b8b572ed0dd3b1e4b02834bc7f852143c575dd172e819d88a082b8edad29ef7e"
201
201
  }
202
202
  }
203
203
  }
@@ -711,6 +711,26 @@ class ClashAPI:
711
711
  except requests.RequestException:
712
712
  return False
713
713
 
714
+ def ui_ok(self) -> bool:
715
+ """True if the core is currently serving the web dashboard at /ui/."""
716
+ try:
717
+ r = requests.get(self.base + "/ui/", headers=self.headers, timeout=3)
718
+ return r.status_code == 200
719
+ except requests.RequestException:
720
+ return False
721
+
722
+ def ui_url(self) -> str:
723
+ """Pre-filled metacubexd setup URL served by the core."""
724
+ host, _, port = self.base[len("http://") :].partition(":")
725
+ q = urllib.parse.urlencode(
726
+ {
727
+ "hostname": host,
728
+ "port": port,
729
+ "secret": self.headers.get("Authorization", "")[len("Bearer ") :],
730
+ }
731
+ )
732
+ return f"{self.base}/ui/#/setup?{q}"
733
+
714
734
  def wait_ready(self, timeout: float = READY_TIMEOUT) -> bool:
715
735
  deadline = time.time() + timeout
716
736
  while time.time() < deadline:
@@ -1137,6 +1157,7 @@ class StatusReport:
1137
1157
  traffic: Optional[dict] = None
1138
1158
  node: Optional[str] = None
1139
1159
  group: Optional[str] = None
1160
+ dashboard: Optional[str] = None
1140
1161
 
1141
1162
 
1142
1163
  class ClashManager:
@@ -1249,7 +1270,7 @@ class ClashManager:
1249
1270
  pid = self.running_pid()
1250
1271
  running = pid is not None
1251
1272
  traffic = None
1252
- node = group = None
1273
+ node = group = dashboard = None
1253
1274
  if running:
1254
1275
  api = self.api()
1255
1276
  try:
@@ -1258,6 +1279,8 @@ class ClashManager:
1258
1279
  g = _primary_selector(proxies, self.state.mode)
1259
1280
  if g:
1260
1281
  node, group = proxies[g].get("now"), g
1282
+ if WebUI.installed() and api.ui_ok():
1283
+ dashboard = f"{api.base}/ui/"
1261
1284
  except click.ClickException:
1262
1285
  pass
1263
1286
  return StatusReport(
@@ -1268,6 +1291,7 @@ class ClashManager:
1268
1291
  traffic=traffic,
1269
1292
  node=node,
1270
1293
  group=group,
1294
+ dashboard=dashboard,
1271
1295
  )
1272
1296
 
1273
1297
  # -- settings (each persists + hot-applies if running) --
@@ -1432,6 +1456,8 @@ def _render_status(rep: StatusReport) -> None:
1432
1456
  )
1433
1457
  if rep.running and s.started_at and not rep.enabled:
1434
1458
  table.add_row("uptime", fmt_uptime(time.time() - s.started_at))
1459
+ if rep.dashboard:
1460
+ table.add_row("dashboard", rep.dashboard)
1435
1461
  if rep.traffic is not None:
1436
1462
  t = rep.traffic
1437
1463
  table.add_row(
@@ -2091,8 +2117,16 @@ def cmd_lan(action):
2091
2117
  # ---- observability ----
2092
2118
 
2093
2119
 
2094
- @cli.command("logs", short_help="Show recent logs, or stream live with -f.")
2095
- @click.option("-f", "--follow", is_flag=True, help="Stream live logs via the API.")
2120
+ @cli.command("logs", short_help="Show recent logs, or stream live with -f/-w.")
2121
+ @click.option(
2122
+ "-f",
2123
+ "--follow",
2124
+ "-w",
2125
+ "--watch",
2126
+ "follow",
2127
+ is_flag=True,
2128
+ help="Stream live logs via the API.",
2129
+ )
2096
2130
  @click.option("-n", "--lines", type=int, default=50, show_default=True)
2097
2131
  @click.option(
2098
2132
  "--level",
@@ -2183,19 +2217,21 @@ def cmd_conns(watch, close):
2183
2217
  )
2184
2218
  def cmd_dash(no_open):
2185
2219
  mgr = ClashManager()
2186
- mgr.require_running()
2187
- newly = not WebUI.installed()
2220
+ api = mgr.require_running()
2188
2221
  WebUI.ensure()
2189
- if newly:
2190
- # The core started before the UI existed; reload so it serves /ui/.
2191
- mgr.apply()
2192
- host, _, port = mgr.state.controller.rpartition(":")
2193
- if host in ("", "0.0.0.0", "::", "*"):
2194
- host = "127.0.0.1"
2195
- q = urllib.parse.urlencode(
2196
- {"hostname": host, "port": port, "secret": mgr.state.secret}
2197
- )
2198
- url = f"http://{host}:{port}/ui/#/setup?{q}"
2222
+ # mihomo only mounts external-ui at startup, so a hot reload won't expose
2223
+ # /ui/. If it isn't being served yet, restart the core (the regenerated
2224
+ # config now includes external-ui because the UI is installed).
2225
+ if not api.ui_ok():
2226
+ with _status("enabling dashboard (restarting core) …"):
2227
+ mgr.restart()
2228
+ api = mgr.api()
2229
+ api.wait_ready()
2230
+ if not api.ui_ok():
2231
+ raise click.ClickException(
2232
+ "the core is running but isn't serving /ui/. Check 'usm clash logs'."
2233
+ )
2234
+ url = api.ui_url()
2199
2235
  console.print(f"[green]✓[/green] dashboard: [bold]{url}[/bold]")
2200
2236
  if not no_open:
2201
2237
  import webbrowser
@@ -18,7 +18,7 @@ version_tuple: tuple[int | str, ...]
18
18
  commit_id: str | None
19
19
  __commit_id__: str | None
20
20
 
21
- __version__ = version = '0.8.2'
22
- __version_tuple__ = version_tuple = (0, 8, 2)
21
+ __version__ = version = '0.8.3'
22
+ __version_tuple__ = version_tuple = (0, 8, 3)
23
23
 
24
24
  __commit_id__ = commit_id = None
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes