tryorchard-cli 0.0.1__tar.gz → 0.0.4__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.
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/PKG-INFO +1 -1
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cli.py +5 -5
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_debugger.py +22 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_net.py +142 -27
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_sandbox.py +9 -8
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/config.py +5 -1
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/wsbridge.py +6 -3
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/pyproject.toml +1 -1
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tryorchard_cli.egg-info/PKG-INFO +1 -1
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/README.md +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/__init__.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/client.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_access.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_exec.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_frida.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_input.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_kernel.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_lifecycle.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_record.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_relay.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_remote.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/cmd_telephony.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/context.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/output.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/ptyshell.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/selector.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/orchard/viewers.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/setup.cfg +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_client.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_config.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_debugger.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_frida.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_input.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_net.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_remote.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_selector.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_viewers.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tests/test_wsbridge.py +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tryorchard_cli.egg-info/SOURCES.txt +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tryorchard_cli.egg-info/dependency_links.txt +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tryorchard_cli.egg-info/entry_points.txt +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/tryorchard_cli.egg-info/requires.txt +0 -0
- {tryorchard_cli-0.0.1 → tryorchard_cli-0.0.4}/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.
|
|
3
|
+
Version: 0.0.4
|
|
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(
|
|
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
|
|
57
|
+
if not token:
|
|
58
58
|
err_console.print(
|
|
59
|
-
"[red]error:[/red] set --
|
|
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,18 @@ _ANDROID = {"android", "cuttlefish", "qemu"}
|
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
def register(app: typer.Typer) -> None:
|
|
25
|
-
app.command("adb", help="
|
|
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("
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
app.command("mitm", help="One-shot HTTPS interception: install a CA + reverse-tunnel to your local proxy + point the device proxy at it.")(mitm)
|
|
33
|
+
# One generic live-view command: it picks the right viewer for the device itself
|
|
34
|
+
# (scrcpy for Android, VNC for an iOS VM, a browser/WebRTC player otherwise).
|
|
35
|
+
app.command("ui", help="Open the device's live screen (auto-picked for the platform).")(ui)
|
|
36
|
+
app.command("screen", hidden=True)(ui) # deprecated alias for `ui`
|
|
33
37
|
app.command("screenshot", help="Save a one-shot screenshot of any sandbox.")(screenshot)
|
|
34
38
|
app.command("connect", help="Forward the device's debug transport (adb) to a local port.")(connect)
|
|
35
39
|
|
|
@@ -93,6 +97,85 @@ def adb(ctx: typer.Context, selector: str,
|
|
|
93
97
|
_amain(go())
|
|
94
98
|
|
|
95
99
|
|
|
100
|
+
# -- idb (iOS device transport) -------------------------------------------
|
|
101
|
+
def idb(ctx: typer.Context, selector: str,
|
|
102
|
+
listen: str = typer.Option("127.0.0.1:22222", "--listen", help="local host:port")):
|
|
103
|
+
"""Expose an iOS device's SSH/debug transport locally, so ssh/scp/idb reach it."""
|
|
104
|
+
inst = _resolve(ctx, selector)
|
|
105
|
+
if _is_android(inst):
|
|
106
|
+
raise fail(f"{inst.get('name')} is an Android device — use `orchard adb`.")
|
|
107
|
+
host, _, port = listen.rpartition(":")
|
|
108
|
+
if not port.isdigit():
|
|
109
|
+
raise fail("--listen must be host:port")
|
|
110
|
+
c = cfg(ctx)
|
|
111
|
+
|
|
112
|
+
def make_ws():
|
|
113
|
+
return wsbridge.connect(wsbridge.ws_url(c, inst["uuid"], "ssh"))
|
|
114
|
+
|
|
115
|
+
def on_ready(bound):
|
|
116
|
+
ok(f"iOS bridge up on {host}:{bound} → {inst.get('name')}")
|
|
117
|
+
console.print(f" ssh -p {bound} root@{host} (Ctrl-C to stop)")
|
|
118
|
+
|
|
119
|
+
async def go():
|
|
120
|
+
loop = asyncio.get_running_loop()
|
|
121
|
+
ready = loop.create_future()
|
|
122
|
+
ready.add_done_callback(lambda f: on_ready(f.result()))
|
|
123
|
+
await wsbridge.serve_local(host, int(port), make_ws, ready)
|
|
124
|
+
|
|
125
|
+
_amain(go())
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
# -- forward / reverse port-forward ---------------------------------------
|
|
129
|
+
def forward(ctx: typer.Context, selector: str,
|
|
130
|
+
spec: str = typer.Argument(..., help="forward <local>:<device>; with -r (reverse) <device>:<local>"),
|
|
131
|
+
reverse: bool = typer.Option(False, "-r", "--reverse",
|
|
132
|
+
help="reverse: expose your local port to the device (device:local)")):
|
|
133
|
+
"""Port-forward between your machine and the device, either direction.
|
|
134
|
+
|
|
135
|
+
Default (forward): a connection to your localhost:<local> reaches the device's
|
|
136
|
+
127.0.0.1:<device> - e.g. `orchard forward <dev> 7777:7777` to hit a service the
|
|
137
|
+
app is listening on. With -r (reverse): the device's 127.0.0.1:<device> reaches a
|
|
138
|
+
service on your localhost:<local> (Android only).
|
|
139
|
+
"""
|
|
140
|
+
inst = _resolve(ctx, selector)
|
|
141
|
+
a, _, b = spec.partition(":")
|
|
142
|
+
if not a.isdigit() or not b.isdigit():
|
|
143
|
+
raise fail("spec must be <port>:<port>")
|
|
144
|
+
c = cfg(ctx)
|
|
145
|
+
|
|
146
|
+
if reverse:
|
|
147
|
+
device_port, local_port = int(a), int(b)
|
|
148
|
+
if _is_android(inst) is False and inst.get("platform") == "ios":
|
|
149
|
+
raise fail("reverse (-r) is Android-only; iOS has no adb reverse.")
|
|
150
|
+
|
|
151
|
+
def log(level, text):
|
|
152
|
+
{"ok": ok, "warn": lambda m: console.print(f"[yellow]{m}[/yellow]"),
|
|
153
|
+
"error": lambda m: console.print(f"[red]{m}[/red]")}.get(level, console.print)(text)
|
|
154
|
+
ok(f"reverse: device :{device_port} -> your 127.0.0.1:{local_port} ({inst.get('name')})")
|
|
155
|
+
rc = _amain(wsbridge.run_tunnel(c, inst["uuid"], "127.0.0.1", local_port, log,
|
|
156
|
+
reverse_port=device_port))
|
|
157
|
+
if rc:
|
|
158
|
+
raise typer.Exit(rc)
|
|
159
|
+
return
|
|
160
|
+
|
|
161
|
+
local_port, device_port = int(a), int(b)
|
|
162
|
+
|
|
163
|
+
def make_ws():
|
|
164
|
+
return wsbridge.connect(wsbridge.ws_url(c, inst["uuid"], "forward", port=device_port))
|
|
165
|
+
|
|
166
|
+
def on_ready(bound):
|
|
167
|
+
ok(f"forward: your 127.0.0.1:{bound} -> device :{device_port} ({inst.get('name')})")
|
|
168
|
+
console.print(f" connect to 127.0.0.1:{bound} (Ctrl-C to stop)")
|
|
169
|
+
|
|
170
|
+
async def go():
|
|
171
|
+
loop = asyncio.get_running_loop()
|
|
172
|
+
ready = loop.create_future()
|
|
173
|
+
ready.add_done_callback(lambda f: on_ready(f.result()))
|
|
174
|
+
await wsbridge.serve_local("127.0.0.1", local_port, make_ws, ready)
|
|
175
|
+
|
|
176
|
+
_amain(go())
|
|
177
|
+
|
|
178
|
+
|
|
96
179
|
# -- gdb (guest kernel) ---------------------------------------------------
|
|
97
180
|
def gdb(ctx: typer.Context, selector: str,
|
|
98
181
|
listen: str = typer.Option("127.0.0.1:1234", "--listen", help="local host:port")):
|
|
@@ -113,7 +196,9 @@ def gdb(ctx: typer.Context, selector: str,
|
|
|
113
196
|
|
|
114
197
|
def on_ready(bound):
|
|
115
198
|
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)")
|
|
199
|
+
console.print(f" gdb <vmlinux> -ex 'target remote {host}:{bound}' (Ctrl-C to stop)")
|
|
200
|
+
console.print(" no vmlinux locally? fetch the matching one: `orchard kernel download` "
|
|
201
|
+
"(`orchard kernel list <node>` shows it) — or omit it to debug without symbols")
|
|
117
202
|
|
|
118
203
|
async def go():
|
|
119
204
|
loop = asyncio.get_running_loop()
|
|
@@ -209,13 +294,45 @@ def cert(ctx: typer.Context, selector: str,
|
|
|
209
294
|
console.print(f"trusted CAs: {r.get('count')}")
|
|
210
295
|
|
|
211
296
|
|
|
212
|
-
# --
|
|
213
|
-
def
|
|
214
|
-
|
|
297
|
+
# -- mitm (one-shot: cert + reverse tunnel + proxy) -----------------------
|
|
298
|
+
def mitm(ctx: typer.Context, selector: str,
|
|
299
|
+
to: str = typer.Option(..., "--to", help="your local proxy as host:port (e.g. 127.0.0.1:8080, a Burp/mitmproxy)"),
|
|
300
|
+
cert_file: str = typer.Option(None, "--cert", help="install this PEM CA file into the device trust store first (your proxy's root CA)")):
|
|
301
|
+
"""One-shot HTTPS interception against a proxy on YOUR machine.
|
|
302
|
+
|
|
303
|
+
Installs your proxy's CA (with --cert; needs a rooted device), opens a reverse
|
|
304
|
+
tunnel to --to, and points the device proxy at it automatically. Holds the tunnel
|
|
305
|
+
open until Ctrl-C. Equivalent to `orchard cert --add` then `orchard tunnel --to`.
|
|
306
|
+
"""
|
|
307
|
+
inst = _resolve(ctx, selector)
|
|
308
|
+
to_host, _, to_port_s = to.rpartition(":")
|
|
309
|
+
if not to_host or not to_port_s.isdigit():
|
|
310
|
+
raise fail("--to must be host:port")
|
|
311
|
+
to_port = int(to_port_s)
|
|
312
|
+
if cert_file:
|
|
313
|
+
with client(ctx) as c:
|
|
314
|
+
r = c.sandbox(inst["uuid"]).install_cert_file(cert_file)
|
|
315
|
+
ok(f"CA {r.get('hash')} installed — {r.get('detail', '')}")
|
|
316
|
+
c = cfg(ctx)
|
|
317
|
+
|
|
318
|
+
def log(level, text):
|
|
319
|
+
{"ok": ok, "warn": lambda m: console.print(f"[yellow]{m}[/yellow]"),
|
|
320
|
+
"error": lambda m: console.print(f"[red]{m}[/red]")}.get(level, console.print)(text)
|
|
321
|
+
|
|
322
|
+
ok(f"interception up — guest proxy -> {to_host}:{to_port} ({inst.get('name')}); Ctrl-C to stop")
|
|
323
|
+
rc = _amain(wsbridge.run_tunnel(c, inst["uuid"], to_host, to_port, log))
|
|
324
|
+
if rc:
|
|
325
|
+
raise typer.Exit(rc)
|
|
326
|
+
|
|
327
|
+
|
|
328
|
+
def _is_android(inst: dict) -> bool:
|
|
329
|
+
return inst.get("platform") == "android" or inst.get("provider") in _ANDROID
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
# -- live viewers (internal; reached via `ui`) ----------------------------
|
|
333
|
+
def _scrcpy_view(ctx: typer.Context, selector: str):
|
|
334
|
+
"""Bridge adb locally, then launch scrcpy against it (Android)."""
|
|
215
335
|
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
336
|
|
|
220
337
|
def run_local(port: int) -> bool:
|
|
221
338
|
serial = f"127.0.0.1:{port}"
|
|
@@ -225,13 +342,11 @@ def scrcpy(ctx: typer.Context, selector: str):
|
|
|
225
342
|
_amain(_bridge_and_view(cfg(ctx), inst["uuid"], "adb", run_local))
|
|
226
343
|
|
|
227
344
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
"""iOS VM: bridge the guest's VNC (RFB) locally and open a viewer."""
|
|
345
|
+
def _vnc_view(ctx: typer.Context, selector: str):
|
|
346
|
+
"""Bridge the guest's VNC (RFB) locally and open a viewer (iOS VM)."""
|
|
231
347
|
inst = _resolve(ctx, selector)
|
|
232
|
-
if inst.get("
|
|
233
|
-
raise fail(f"{inst.get('name')}
|
|
234
|
-
"Android → `orchard scrcpy`; iOS simulator → `orchard screen`.")
|
|
348
|
+
if not inst.get("vnc") and inst.get("platform") != "ios":
|
|
349
|
+
raise fail(f"{inst.get('name')} has no live screen. Try `orchard screenshot`.")
|
|
235
350
|
password = (inst.get("vnc") or {}).get("password", "alpine")
|
|
236
351
|
|
|
237
352
|
def run_local(port: int) -> bool:
|
|
@@ -263,19 +378,19 @@ def connect(ctx: typer.Context, selector: str,
|
|
|
263
378
|
return adb(ctx, selector, listen)
|
|
264
379
|
|
|
265
380
|
|
|
266
|
-
def
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
"""
|
|
381
|
+
def ui(ctx: typer.Context, selector: str,
|
|
382
|
+
webrtc: bool = typer.Option(False, "--webrtc",
|
|
383
|
+
help="Force the browser/WebRTC player.")):
|
|
384
|
+
"""Open the device's live screen, auto-picking the viewer for the platform
|
|
385
|
+
(scrcpy for Android, VNC for an iOS VM, a browser player otherwise)."""
|
|
270
386
|
inst = _resolve(ctx, selector)
|
|
271
387
|
if webrtc:
|
|
272
388
|
return _webrtc_view(ctx, inst)
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
# iOS simulator (baguette) and anything else: one-shot screenshot.
|
|
389
|
+
if _is_android(inst):
|
|
390
|
+
return _scrcpy_view(ctx, selector)
|
|
391
|
+
if inst.get("vnc") or inst.get("platform") == "ios":
|
|
392
|
+
return _vnc_view(ctx, selector)
|
|
393
|
+
# anything else: one-shot screenshot.
|
|
279
394
|
_save_screenshot(ctx, inst, None)
|
|
280
395
|
|
|
281
396
|
|
|
@@ -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",
|
|
26
|
-
|
|
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", "
|
|
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("
|
|
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")],
|
|
51
|
+
[["uuid", full.get("uuid")],
|
|
51
52
|
["platform", full.get("platform")], ["state", full.get("state")],
|
|
52
|
-
["tag", tag_cell(full)], ["
|
|
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
|
|
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. `
|
|
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.
|
|
3
|
+
version = "0.0.4"
|
|
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.
|
|
3
|
+
Version: 0.0.4
|
|
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
|
|
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
|