tryorchard-cli 0.0.1__tar.gz → 0.0.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 (43) hide show
  1. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/PKG-INFO +1 -1
  2. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cli.py +5 -5
  3. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_debugger.py +22 -0
  4. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_net.py +110 -27
  5. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_sandbox.py +9 -8
  6. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/config.py +5 -1
  7. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/wsbridge.py +6 -3
  8. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/pyproject.toml +1 -1
  9. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tryorchard_cli.egg-info/PKG-INFO +1 -1
  10. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/README.md +0 -0
  11. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/__init__.py +0 -0
  12. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/client.py +0 -0
  13. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_access.py +0 -0
  14. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_exec.py +0 -0
  15. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_frida.py +0 -0
  16. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_input.py +0 -0
  17. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_kernel.py +0 -0
  18. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_lifecycle.py +0 -0
  19. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_record.py +0 -0
  20. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_relay.py +0 -0
  21. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_remote.py +0 -0
  22. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/cmd_telephony.py +0 -0
  23. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/context.py +0 -0
  24. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/output.py +0 -0
  25. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/ptyshell.py +0 -0
  26. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/selector.py +0 -0
  27. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/orchard/viewers.py +0 -0
  28. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/setup.cfg +0 -0
  29. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_client.py +0 -0
  30. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_config.py +0 -0
  31. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_debugger.py +0 -0
  32. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_frida.py +0 -0
  33. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_input.py +0 -0
  34. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_net.py +0 -0
  35. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_remote.py +0 -0
  36. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_selector.py +0 -0
  37. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_viewers.py +0 -0
  38. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tests/test_wsbridge.py +0 -0
  39. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tryorchard_cli.egg-info/SOURCES.txt +0 -0
  40. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tryorchard_cli.egg-info/dependency_links.txt +0 -0
  41. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tryorchard_cli.egg-info/entry_points.txt +0 -0
  42. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tryorchard_cli.egg-info/requires.txt +0 -0
  43. {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.3}/tryorchard_cli.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tryorchard-cli
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: Orchard CLI — drive sandboxes (sandbox/snapshot/template/team/key management and live adb/scrcpy/vnc/shell/logs/files) from the terminal.
5
5
  License: MIT
6
6
  Requires-Python: >=3.10
@@ -16,7 +16,7 @@ from . import (cmd_access, cmd_debugger, cmd_exec, cmd_frida, cmd_input,
16
16
  cmd_kernel, cmd_lifecycle, cmd_net, cmd_record, cmd_relay,
17
17
  cmd_remote, cmd_sandbox, cmd_telephony)
18
18
  from .client import ApiError
19
- from .config import Config
19
+ from .config import Config, DEFAULT_API_URL
20
20
  from .output import err_console
21
21
  from .selector import SelectorError
22
22
 
@@ -45,8 +45,8 @@ cmd_remote.register(app) # remote (cloud) sandboxes: create/ls/shell/push/pull
45
45
  @app.callback()
46
46
  def main(
47
47
  ctx: typer.Context,
48
- url: str = typer.Option(None, "--url", envvar=["ORCHARD_API_URL", "ORCHARD_URL"],
49
- help="Control-plane URL (or $ORCHARD_API_URL)."),
48
+ url: str = typer.Option(DEFAULT_API_URL, "--url", envvar=["ORCHARD_API_URL", "ORCHARD_URL"],
49
+ help="Control-plane URL (defaults to Orchard Cloud; or $ORCHARD_API_URL)."),
50
50
  token: str = typer.Option(None, "--token", envvar="ORCHARD_API_KEY",
51
51
  help="Orchard API key (or $ORCHARD_API_KEY)."),
52
52
  org: str = typer.Option(None, "--org", envvar="ORCHARD_ORG", help="Org slug."),
@@ -54,9 +54,9 @@ def main(
54
54
  json_output: bool = typer.Option(False, "--json", help="Machine-readable JSON output."),
55
55
  ):
56
56
  """Resolve connection config once and hang it on the context."""
57
- if not url or not token:
57
+ if not token:
58
58
  err_console.print(
59
- "[red]error:[/red] set --url/$ORCHARD_API_URL and --token/$ORCHARD_API_KEY")
59
+ "[red]error:[/red] set --token or $ORCHARD_API_KEY (get one at https://platform.tryorchard.dev)")
60
60
  raise typer.Exit(2)
61
61
  ctx.obj = Config(url=url, token=token, org=org, ws=ws, json=json_output)
62
62
 
@@ -57,6 +57,28 @@ def start(ctx: typer.Context, selector: str,
57
57
  emit(cfg(ctx), res) if cfg(ctx).json else ok(f"lldb-server start → {inst.get('name')}")
58
58
 
59
59
 
60
+ @app.command()
61
+ def gdb(ctx: typer.Context, selector: str,
62
+ process: str = typer.Option(..., "--process", "-p",
63
+ help="Running app process (package) to attach gdb to.")) -> None:
64
+ """Attach a gdbserver to an app for gdb/pwndbg (needs a rooted device + the app
65
+ running). Then open the tunnel with `orchard gdb <selector>` and `target remote` it."""
66
+ inst, res = _debugger(ctx, selector, action="gdb", process=process)
67
+ if cfg(ctx).json:
68
+ emit(cfg(ctx), res)
69
+ else:
70
+ ok(f"gdbserver attached to {process} (pid {res.get('pid')}) on {inst.get('name')}")
71
+ print(f" tunnel it: orchard gdb {selector}")
72
+ print(f" then: {res.get('connect', 'gdb-multiarch -ex \"target remote …\"')}")
73
+
74
+
75
+ @app.command("gdb-stop")
76
+ def gdb_stop(ctx: typer.Context, selector: str) -> None:
77
+ """Detach gdb — stop the on-device gdbserver (the app resumes)."""
78
+ inst, res = _debugger(ctx, selector, action="gdb-detach")
79
+ emit(cfg(ctx), res) if cfg(ctx).json else ok(f"gdb detached → {inst.get('name')}")
80
+
81
+
60
82
  @app.command()
61
83
  def console(ctx: typer.Context, selector: str,
62
84
  process: str = typer.Option(None, "--process", "-p",
@@ -22,14 +22,17 @@ _ANDROID = {"android", "cuttlefish", "qemu"}
22
22
 
23
23
 
24
24
  def register(app: typer.Typer) -> None:
25
- app.command("adb", help="Bridge a sandbox's adb to a local TCP port.")(adb)
25
+ app.command("adb", help="Android: bridge the device's adb transport to a local TCP port.")(adb)
26
+ app.command("idb", help="iOS: bridge the device's SSH/debug transport to a local TCP port.")(idb)
27
+ app.command("forward", help="Port-forward a local port to a device port (or -r to expose a local port to the device).")(forward)
26
28
  app.command("gdb", help="Bridge a debug sandbox's guest-kernel gdb stub to a local port.")(gdb)
27
29
  app.command("tunnel", help="Reverse-tunnel a local proxy into the guest.")(tunnel)
28
30
  app.command("proxy", help="Show, set, or clear the device's HTTP(S) proxy.")(proxy)
29
31
  app.command("cert", help="Install/list/remove a custom CA in the device's system trust store.")(cert)
30
- app.command("scrcpy", help="Android live screen via adb + scrcpy.")(scrcpy)
31
- app.command("vnc", help="iOS-VM live screen via VNC.")(vnc)
32
- app.command("screen", help="Live screen, auto-picked for the platform.")(screen)
32
+ # One generic live-view command: it picks the right viewer for the device itself
33
+ # (scrcpy for Android, VNC for an iOS VM, a browser/WebRTC player otherwise).
34
+ app.command("ui", help="Open the device's live screen (auto-picked for the platform).")(ui)
35
+ app.command("screen", hidden=True)(ui) # deprecated alias for `ui`
33
36
  app.command("screenshot", help="Save a one-shot screenshot of any sandbox.")(screenshot)
34
37
  app.command("connect", help="Forward the device's debug transport (adb) to a local port.")(connect)
35
38
 
@@ -93,6 +96,85 @@ def adb(ctx: typer.Context, selector: str,
93
96
  _amain(go())
94
97
 
95
98
 
99
+ # -- idb (iOS device transport) -------------------------------------------
100
+ def idb(ctx: typer.Context, selector: str,
101
+ listen: str = typer.Option("127.0.0.1:22222", "--listen", help="local host:port")):
102
+ """Expose an iOS device's SSH/debug transport locally, so ssh/scp/idb reach it."""
103
+ inst = _resolve(ctx, selector)
104
+ if _is_android(inst):
105
+ raise fail(f"{inst.get('name')} is an Android device — use `orchard adb`.")
106
+ host, _, port = listen.rpartition(":")
107
+ if not port.isdigit():
108
+ raise fail("--listen must be host:port")
109
+ c = cfg(ctx)
110
+
111
+ def make_ws():
112
+ return wsbridge.connect(wsbridge.ws_url(c, inst["uuid"], "ssh"))
113
+
114
+ def on_ready(bound):
115
+ ok(f"iOS bridge up on {host}:{bound} → {inst.get('name')}")
116
+ console.print(f" ssh -p {bound} root@{host} (Ctrl-C to stop)")
117
+
118
+ async def go():
119
+ loop = asyncio.get_running_loop()
120
+ ready = loop.create_future()
121
+ ready.add_done_callback(lambda f: on_ready(f.result()))
122
+ await wsbridge.serve_local(host, int(port), make_ws, ready)
123
+
124
+ _amain(go())
125
+
126
+
127
+ # -- forward / reverse port-forward ---------------------------------------
128
+ def forward(ctx: typer.Context, selector: str,
129
+ spec: str = typer.Argument(..., help="forward <local>:<device>; with -r (reverse) <device>:<local>"),
130
+ reverse: bool = typer.Option(False, "-r", "--reverse",
131
+ help="reverse: expose your local port to the device (device:local)")):
132
+ """Port-forward between your machine and the device, either direction.
133
+
134
+ Default (forward): a connection to your localhost:<local> reaches the device's
135
+ 127.0.0.1:<device> - e.g. `orchard forward <dev> 7777:7777` to hit a service the
136
+ app is listening on. With -r (reverse): the device's 127.0.0.1:<device> reaches a
137
+ service on your localhost:<local> (Android only).
138
+ """
139
+ inst = _resolve(ctx, selector)
140
+ a, _, b = spec.partition(":")
141
+ if not a.isdigit() or not b.isdigit():
142
+ raise fail("spec must be <port>:<port>")
143
+ c = cfg(ctx)
144
+
145
+ if reverse:
146
+ device_port, local_port = int(a), int(b)
147
+ if _is_android(inst) is False and inst.get("platform") == "ios":
148
+ raise fail("reverse (-r) is Android-only; iOS has no adb reverse.")
149
+
150
+ def log(level, text):
151
+ {"ok": ok, "warn": lambda m: console.print(f"[yellow]{m}[/yellow]"),
152
+ "error": lambda m: console.print(f"[red]{m}[/red]")}.get(level, console.print)(text)
153
+ ok(f"reverse: device :{device_port} -> your 127.0.0.1:{local_port} ({inst.get('name')})")
154
+ rc = _amain(wsbridge.run_tunnel(c, inst["uuid"], "127.0.0.1", local_port, log,
155
+ reverse_port=device_port))
156
+ if rc:
157
+ raise typer.Exit(rc)
158
+ return
159
+
160
+ local_port, device_port = int(a), int(b)
161
+
162
+ def make_ws():
163
+ return wsbridge.connect(wsbridge.ws_url(c, inst["uuid"], "forward", port=device_port))
164
+
165
+ def on_ready(bound):
166
+ ok(f"forward: your 127.0.0.1:{bound} -> device :{device_port} ({inst.get('name')})")
167
+ console.print(f" connect to 127.0.0.1:{bound} (Ctrl-C to stop)")
168
+
169
+ async def go():
170
+ loop = asyncio.get_running_loop()
171
+ ready = loop.create_future()
172
+ ready.add_done_callback(lambda f: on_ready(f.result()))
173
+ await wsbridge.serve_local("127.0.0.1", local_port, make_ws, ready)
174
+
175
+ _amain(go())
176
+
177
+
96
178
  # -- gdb (guest kernel) ---------------------------------------------------
97
179
  def gdb(ctx: typer.Context, selector: str,
98
180
  listen: str = typer.Option("127.0.0.1:1234", "--listen", help="local host:port")):
@@ -113,7 +195,9 @@ def gdb(ctx: typer.Context, selector: str,
113
195
 
114
196
  def on_ready(bound):
115
197
  ok(f"kernel gdb bridge up on {host}:{bound} → {inst.get('name')}")
116
- console.print(f" gdb vmlinux -ex 'target remote {host}:{bound}' (Ctrl-C to stop)")
198
+ console.print(f" gdb <vmlinux> -ex 'target remote {host}:{bound}' (Ctrl-C to stop)")
199
+ console.print(" no vmlinux locally? fetch the matching one: `orchard kernel download` "
200
+ "(`orchard kernel list <node>` shows it) — or omit it to debug without symbols")
117
201
 
118
202
  async def go():
119
203
  loop = asyncio.get_running_loop()
@@ -209,13 +293,14 @@ def cert(ctx: typer.Context, selector: str,
209
293
  console.print(f"trusted CAs: {r.get('count')}")
210
294
 
211
295
 
212
- # -- scrcpy ---------------------------------------------------------------
213
- def scrcpy(ctx: typer.Context, selector: str):
214
- """Android: bridge adb locally, then launch scrcpy against it."""
296
+ def _is_android(inst: dict) -> bool:
297
+ return inst.get("platform") == "android" or inst.get("provider") in _ANDROID
298
+
299
+
300
+ # -- live viewers (internal; reached via `ui`) ----------------------------
301
+ def _scrcpy_view(ctx: typer.Context, selector: str):
302
+ """Bridge adb locally, then launch scrcpy against it (Android)."""
215
303
  inst = _resolve(ctx, selector)
216
- if inst.get("provider") not in _ANDROID:
217
- raise fail(f"scrcpy is Android-only; {inst.get('name')} is {inst.get('provider')}. "
218
- "Use `orchard vnc` (iOS VM) or `orchard screen`.")
219
304
 
220
305
  def run_local(port: int) -> bool:
221
306
  serial = f"127.0.0.1:{port}"
@@ -225,13 +310,11 @@ def scrcpy(ctx: typer.Context, selector: str):
225
310
  _amain(_bridge_and_view(cfg(ctx), inst["uuid"], "adb", run_local))
226
311
 
227
312
 
228
- # -- vnc ------------------------------------------------------------------
229
- def vnc(ctx: typer.Context, selector: str):
230
- """iOS VM: bridge the guest's VNC (RFB) locally and open a viewer."""
313
+ def _vnc_view(ctx: typer.Context, selector: str):
314
+ """Bridge the guest's VNC (RFB) locally and open a viewer (iOS VM)."""
231
315
  inst = _resolve(ctx, selector)
232
- if inst.get("provider") != "vphone" and not inst.get("vnc"):
233
- raise fail(f"{inst.get('name')} ({inst.get('provider')}) has no VNC. "
234
- "Android → `orchard scrcpy`; iOS simulator → `orchard screen`.")
316
+ if not inst.get("vnc") and inst.get("platform") != "ios":
317
+ raise fail(f"{inst.get('name')} has no live screen. Try `orchard screenshot`.")
235
318
  password = (inst.get("vnc") or {}).get("password", "alpine")
236
319
 
237
320
  def run_local(port: int) -> bool:
@@ -263,19 +346,19 @@ def connect(ctx: typer.Context, selector: str,
263
346
  return adb(ctx, selector, listen)
264
347
 
265
348
 
266
- def screen(ctx: typer.Context, selector: str,
267
- webrtc: bool = typer.Option(False, "--webrtc",
268
- help="Live screen over WebRTC (opens a browser player).")):
269
- """Pick the right live view for the platform."""
349
+ def ui(ctx: typer.Context, selector: str,
350
+ webrtc: bool = typer.Option(False, "--webrtc",
351
+ help="Force the browser/WebRTC player.")):
352
+ """Open the device's live screen, auto-picking the viewer for the platform
353
+ (scrcpy for Android, VNC for an iOS VM, a browser player otherwise)."""
270
354
  inst = _resolve(ctx, selector)
271
355
  if webrtc:
272
356
  return _webrtc_view(ctx, inst)
273
- provider = inst.get("provider")
274
- if provider in _ANDROID:
275
- return scrcpy(ctx, selector)
276
- if provider == "vphone":
277
- return vnc(ctx, selector)
278
- # iOS simulator (baguette) and anything else: one-shot screenshot.
357
+ if _is_android(inst):
358
+ return _scrcpy_view(ctx, selector)
359
+ if inst.get("vnc") or inst.get("platform") == "ios":
360
+ return _vnc_view(ctx, selector)
361
+ # anything else: one-shot screenshot.
279
362
  _save_screenshot(ctx, inst, None)
280
363
 
281
364
 
@@ -22,18 +22,19 @@ def _resolve(ctx: typer.Context, c, selector: str) -> dict:
22
22
 
23
23
  @app.command("list")
24
24
  def list_(ctx: typer.Context,
25
- all_: bool = typer.Option(False, "--all", "-a", help="Include stopped/remote rows too.")):
26
- """List sandboxes (name, uuid, provider, state, tag, node)."""
25
+ all_: bool = typer.Option(False, "--all", "-a",
26
+ help="Show stopped/unknown devices too (default: running only).")):
27
+ """List your running sandboxes (name, uuid, platform, state, tag, region)."""
27
28
  with client(ctx) as c:
28
- data = c.get("/instances") or {}
29
+ data = c.get("/instances?all=1" if all_ else "/instances") or {}
29
30
  rows = data.get("instances", [])
30
31
  if cfg(ctx).json:
31
32
  return emit(cfg(ctx), rows)
32
33
  if not rows:
33
- return ok("no sandboxes")
34
- table("Sandboxes", ["name", "uuid", "provider", "state", "tag", "node"],
34
+ return ok("no running sandboxes" if not all_ else "no sandboxes")
35
+ table("Sandboxes", ["name", "uuid", "platform", "state", "tag", "region"],
35
36
  [[i.get("display_name") or i.get("name"), (i.get("uuid") or "")[:8],
36
- i.get("provider"), i.get("state"), tag_cell(i), i.get("node") or "-"]
37
+ i.get("platform"), i.get("state"), tag_cell(i), i.get("region") or "-"]
37
38
  for i in rows])
38
39
 
39
40
 
@@ -47,9 +48,9 @@ def get(ctx: typer.Context, selector: str = typer.Argument(..., help="uuid / nam
47
48
  return emit(cfg(ctx), full)
48
49
  table(full.get("display_name") or full.get("name"),
49
50
  ["field", "value"],
50
- [["uuid", full.get("uuid")], ["provider", full.get("provider")],
51
+ [["uuid", full.get("uuid")],
51
52
  ["platform", full.get("platform")], ["state", full.get("state")],
52
- ["tag", tag_cell(full)], ["node", full.get("node")],
53
+ ["tag", tag_cell(full)], ["region", full.get("region")],
53
54
  ["cpu", full.get("hardware", {}).get("cpu")],
54
55
  ["memory_mb", full.get("hardware", {}).get("memory_mb")],
55
56
  ["notes", full.get("notes")]])
@@ -9,6 +9,10 @@ import os
9
9
  from dataclasses import dataclass
10
10
  from urllib.parse import urlsplit
11
11
 
12
+ # Default control-plane endpoint when neither --url nor $ORCHARD_API_URL is set.
13
+ # Self-hosters and local dev override it via the flag or env var.
14
+ DEFAULT_API_URL = "https://app.tryorchard.dev"
15
+
12
16
 
13
17
  @dataclass
14
18
  class Config:
@@ -36,7 +40,7 @@ def from_env(url: str | None, token: str | None, org: str | None,
36
40
  """Flag value wins over env; returns None if url or token is missing so the
37
41
  caller can print a friendly error (Typer envvar= already folds env in, this
38
42
  is the fallback/validation path for direct construction)."""
39
- url = url or os.environ.get("ORCHARD_API_URL") or os.environ.get("ORCHARD_URL")
43
+ url = url or os.environ.get("ORCHARD_API_URL") or os.environ.get("ORCHARD_URL") or DEFAULT_API_URL
40
44
  token = token or os.environ.get("ORCHARD_API_KEY")
41
45
  org = org or os.environ.get("ORCHARD_ORG")
42
46
  ws = ws or os.environ.get("ORCHARD_WS")
@@ -151,12 +151,15 @@ async def _egress(ws, log) -> None:
151
151
  await pump(ws, reader, writer)
152
152
 
153
153
 
154
- async def run_tunnel(cfg: Config, uuid: str, to_host: str | None, to_port: int, log) -> int:
154
+ async def run_tunnel(cfg: Config, uuid: str, to_host: str | None, to_port: int, log,
155
+ reverse_port: int | None = None) -> int:
155
156
  """Hold the reverse-tunnel control channel open; for each `open{sid}` the guest
156
157
  makes, bridge a data channel. With `to_host`, every stream is forwarded to that
157
158
  one local proxy (e.g. Burp). Without it (egress mode), each stream is served as
158
159
  an HTTP(S) proxy request and dialed to its real destination from this machine —
159
- a full tunnel: the device reaches anything we can. `log(level, text)` prints."""
160
+ a full tunnel: the device reaches anything we can. `reverse_port` turns it into a
161
+ raw port-forward: the agent `adb reverse`s that device port into the tunnel, and
162
+ each stream is relayed straight to `to_host:to_port`. `log(level, text)` prints."""
160
163
  egress = not to_host
161
164
  tasks: set[asyncio.Task] = set()
162
165
 
@@ -171,7 +174,7 @@ async def run_tunnel(cfg: Config, uuid: str, to_host: str | None, to_port: int,
171
174
  except Exception as e: # a single stream failing must not kill the tunnel
172
175
  log("warn", f"stream {sid[:8]} ended: {e}")
173
176
 
174
- async with connect(ws_url(cfg, uuid, "tunnel")) as control:
177
+ async with connect(ws_url(cfg, uuid, "tunnel", reverse_port=reverse_port)) as control:
175
178
  async for raw in control:
176
179
  try:
177
180
  msg = json.loads(raw)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "tryorchard-cli"
3
- version = "0.0.1"
3
+ version = "0.0.3"
4
4
  description = "Orchard CLI — drive sandboxes (sandbox/snapshot/template/team/key management and live adb/scrcpy/vnc/shell/logs/files) from the terminal."
5
5
  readme = "README.md"
6
6
  license = { text = "MIT" }
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: tryorchard-cli
3
- Version: 0.0.1
3
+ Version: 0.0.3
4
4
  Summary: Orchard CLI — drive sandboxes (sandbox/snapshot/template/team/key management and live adb/scrcpy/vnc/shell/logs/files) from the terminal.
5
5
  License: MIT
6
6
  Requires-Python: >=3.10
File without changes
File without changes