RemoteRF 2.13.2__tar.gz → 2.13.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.
- {remoterf-2.13.2/src/remoterf.egg-info → remoterf-2.13.4}/PKG-INFO +24 -4
- {remoterf-2.13.2 → remoterf-2.13.4}/README.md +23 -3
- {remoterf-2.13.2 → remoterf-2.13.4}/pyproject.toml +1 -1
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/config/cert_fetcher.py +45 -2
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/config/config.py +19 -6
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/app.py +8 -16
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/remoterf_cli.py +19 -19
- {remoterf-2.13.2 → remoterf-2.13.4/src/remoterf.egg-info}/PKG-INFO +24 -4
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf.egg-info/SOURCES.txt +1 -0
- remoterf-2.13.4/tests/test_ca_pin.py +95 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_cli_login_fresh.py +77 -2
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_config_address.py +10 -2
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_homes.py +3 -3
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_remoterf_cli.py +10 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/LICENSE +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/setup.cfg +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/setup.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/_remoterf_alias.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/admin.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/agent_cli.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/agent_docs.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/deployment_capabilities.proto +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/deployment_capabilities_pb2.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/deployment_capabilities_pb2_grpc.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/grpc.proto +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/grpc_pb2.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/grpc_pb2_grpc.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/v2_codec.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/tos_notice.txt +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/utils/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/utils/ansi_codes.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/utils/api_token.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/utils/banner.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/utils/list_string.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/utils/process_arg.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/config/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/acc_login.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/availability.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/banner_note.txt +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/direct_path.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/dynamic_v2_transport.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/grpc_acc.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/grpc_client.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/messages.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/secure_channel.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/core/v2_errors.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/data/agent_guide.md +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/data/mcp_tools.json +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/deployment/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/deployment/backend.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/deployment/direct.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/deployment/homes.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/deployment/http.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/deployment/lanpass.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/deployment/state.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/_virtual.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/adalm_pluto/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/adalm_pluto/adalm_pluto_remote.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/dynamic_device.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/dynamic_v2.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/hackrf/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/hackrf/hackrf_remote.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/rtl_sdr/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/rtl_sdr/rtl_sdr_remote.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/schema_review.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/sim_sdr/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/sim_sdr/sim_sdr_remote.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/support/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/support/ti_mmwave.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/support/uhd.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/support/uhd_dsp.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/support/uhd_v2.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/ti_mmwave/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/ti_mmwave/ti_mmwave_remote.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/usrp/__init__.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/usrp/usrp_remote.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/drivers/usrp/usrp_remote.pyi +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/mcp_server.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/ops.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/version.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf.egg-info/dependency_links.txt +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf.egg-info/entry_points.txt +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf.egg-info/requires.txt +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf.egg-info/top_level.txt +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_agent_cli.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_agent_docs.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_banner.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_batch.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_bundled_drivers.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_deployment_accounts.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_device_routes.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_devices_api.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_direct_path_fixed.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_direct_path_global.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_direct_path_partner.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_direct_path_race.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_direct_path_relay.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_dynamic_device_codegen.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_dynamic_v2.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_federated_devices.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_fetch_idl_fallback.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_finish_prompt.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_gate_i_direct_path.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_grpc_client_target.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_lan_fallback.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_mcp_server.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_messages.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_native_account_credentials.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_native_devices.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_old_import_name.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_ops.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_partner_dynamic_v2.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_pluto_virtual.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_process_arg.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_relay_paging.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_remote_admin.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_rx_readahead.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_schema_review.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_ti_mmwave.py +0 -0
- {remoterf-2.13.2 → remoterf-2.13.4}/tests/test_upgrade_rescue.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: remoterf
|
|
3
|
-
Version: 2.13.
|
|
3
|
+
Version: 2.13.4
|
|
4
4
|
Summary: A python API to remotely access signal centric hardware. Client-side only! Courtesy of Wireless Lab @ UCLA & Prof. Ian Roberts.
|
|
5
5
|
Author-email: Ethan Ge <84103791+ethange1@users.noreply.github.com>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -121,6 +121,26 @@ generic native dispatch, but are not release-qualified as exact UHD overload
|
|
|
121
121
|
parity until the server's UHD 4.10 target-introspection and hardware
|
|
122
122
|
differential gates pass.
|
|
123
123
|
|
|
124
|
+
## Wi-Fi
|
|
125
|
+
|
|
126
|
+
USB Wi-Fi clients are generated from the server's `wifi` schema and installed
|
|
127
|
+
under the matching package name:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from remoterf.drivers import ensure_driver
|
|
131
|
+
|
|
132
|
+
token = "reservation-token"
|
|
133
|
+
ensure_driver(token=token)
|
|
134
|
+
|
|
135
|
+
from remoterf.drivers.wifi import WifiDongle
|
|
136
|
+
|
|
137
|
+
radio = WifiDongle(token)
|
|
138
|
+
print(radio.scan())
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Existing server inventories that use `device_type: wifi_dongle` are accepted
|
|
142
|
+
as `wifi` during upgrade. New inventory entries should use `device_type: wifi`.
|
|
143
|
+
|
|
124
144
|
## RTL-SDR
|
|
125
145
|
|
|
126
146
|
RTL-SDR clients are generated from the server's `rtl_sdr` schema. The machine
|
|
@@ -295,17 +315,17 @@ Welcome to Remote RF Account System.
|
|
|
295
315
|
Please login or register to continue. (l/r):
|
|
296
316
|
```
|
|
297
317
|
|
|
298
|
-
- Once in, input `help` to see all
|
|
318
|
+
- Once in, input `help` to see all available commands.
|
|
299
319
|
|
|
300
320
|
### 3. **Reserve Device**:
|
|
301
321
|
```bash
|
|
302
|
-
getdev # To view all
|
|
322
|
+
getdev # To view all available devices
|
|
303
323
|
|
|
304
324
|
# Note the device ID. You will need this later to reserve said device
|
|
305
325
|
```
|
|
306
326
|
|
|
307
327
|
```bash
|
|
308
|
-
getres # To view times not
|
|
328
|
+
getres # To view times not available
|
|
309
329
|
|
|
310
330
|
# Optionally, you can also view all reservations, and determine a time slot you want a specific device reserved
|
|
311
331
|
```
|
|
@@ -94,6 +94,26 @@ generic native dispatch, but are not release-qualified as exact UHD overload
|
|
|
94
94
|
parity until the server's UHD 4.10 target-introspection and hardware
|
|
95
95
|
differential gates pass.
|
|
96
96
|
|
|
97
|
+
## Wi-Fi
|
|
98
|
+
|
|
99
|
+
USB Wi-Fi clients are generated from the server's `wifi` schema and installed
|
|
100
|
+
under the matching package name:
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
from remoterf.drivers import ensure_driver
|
|
104
|
+
|
|
105
|
+
token = "reservation-token"
|
|
106
|
+
ensure_driver(token=token)
|
|
107
|
+
|
|
108
|
+
from remoterf.drivers.wifi import WifiDongle
|
|
109
|
+
|
|
110
|
+
radio = WifiDongle(token)
|
|
111
|
+
print(radio.scan())
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Existing server inventories that use `device_type: wifi_dongle` are accepted
|
|
115
|
+
as `wifi` during upgrade. New inventory entries should use `device_type: wifi`.
|
|
116
|
+
|
|
97
117
|
## RTL-SDR
|
|
98
118
|
|
|
99
119
|
RTL-SDR clients are generated from the server's `rtl_sdr` schema. The machine
|
|
@@ -268,17 +288,17 @@ Welcome to Remote RF Account System.
|
|
|
268
288
|
Please login or register to continue. (l/r):
|
|
269
289
|
```
|
|
270
290
|
|
|
271
|
-
- Once in, input `help` to see all
|
|
291
|
+
- Once in, input `help` to see all available commands.
|
|
272
292
|
|
|
273
293
|
### 3. **Reserve Device**:
|
|
274
294
|
```bash
|
|
275
|
-
getdev # To view all
|
|
295
|
+
getdev # To view all available devices
|
|
276
296
|
|
|
277
297
|
# Note the device ID. You will need this later to reserve said device
|
|
278
298
|
```
|
|
279
299
|
|
|
280
300
|
```bash
|
|
281
|
-
getres # To view times not
|
|
301
|
+
getres # To view times not available
|
|
282
302
|
|
|
283
303
|
# Optionally, you can also view all reservations, and determine a time slot you want a specific device reserved
|
|
284
304
|
```
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "remoterf"
|
|
7
|
-
version = "2.13.
|
|
7
|
+
version = "2.13.4"
|
|
8
8
|
description = "A python API to remotely access signal centric hardware. Client-side only! Courtesy of Wireless Lab @ UCLA & Prof. Ian Roberts."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "GPL-3.0-or-later"
|
|
@@ -19,7 +19,9 @@ from __future__ import annotations
|
|
|
19
19
|
|
|
20
20
|
import hashlib
|
|
21
21
|
import os
|
|
22
|
+
import re
|
|
22
23
|
import socket
|
|
24
|
+
import sys
|
|
23
25
|
import urllib.error
|
|
24
26
|
import urllib.request
|
|
25
27
|
from pathlib import Path
|
|
@@ -63,6 +65,23 @@ def sha256_fingerprint_pem(pem_bytes: bytes) -> str:
|
|
|
63
65
|
h = hashlib.sha256(pem_bytes).hexdigest()
|
|
64
66
|
return ":".join(h[i:i+2] for i in range(0, len(h), 2))
|
|
65
67
|
|
|
68
|
+
def normalize_sha256(value: str) -> str:
|
|
69
|
+
"""'sha256:AB:CD..' / 'abcd..' -> 'abcd..'; '' when it is not a sha256."""
|
|
70
|
+
v = (value or "").strip().lower()
|
|
71
|
+
if v.startswith("sha256:"):
|
|
72
|
+
v = v[len("sha256:"):]
|
|
73
|
+
v = v.replace(":", "")
|
|
74
|
+
return v if re.fullmatch(r"[0-9a-f]{64}", v) else ""
|
|
75
|
+
|
|
76
|
+
def _dotenv_get_key(env_path: Path, key: str) -> str:
|
|
77
|
+
if not env_path.exists():
|
|
78
|
+
return ""
|
|
79
|
+
for line in env_path.read_text(encoding="utf-8", errors="ignore").splitlines():
|
|
80
|
+
stripped = line.strip()
|
|
81
|
+
if stripped.startswith(key + "="):
|
|
82
|
+
return stripped.split("=", 1)[1].strip().strip("'\"")
|
|
83
|
+
return ""
|
|
84
|
+
|
|
66
85
|
def _fetch_http(host: str, port: int, timeout_sec: float) -> bytes:
|
|
67
86
|
url = f"http://{host}:{port}/ca.crt"
|
|
68
87
|
req = urllib.request.Request(url, method="GET")
|
|
@@ -160,6 +179,7 @@ def fetch_and_save_ca_cert(
|
|
|
160
179
|
overwrite: bool = True,
|
|
161
180
|
write_env: bool = True,
|
|
162
181
|
env_path: Optional[str | Path] = None,
|
|
182
|
+
expected_sha256: Optional[str] = None,
|
|
163
183
|
) -> bool:
|
|
164
184
|
"""
|
|
165
185
|
Fetch CA cert and save. Optionally writes REMOTERF_CA_CERT into ~/.config/remoterf-client/.env
|
|
@@ -167,12 +187,21 @@ def fetch_and_save_ca_cert(
|
|
|
167
187
|
|
|
168
188
|
Args:
|
|
169
189
|
write_env: if True, updates REMOTERF_CA_CERT in env file to point at saved cert
|
|
190
|
+
and pins its digest as REMOTERF_CA_SHA256
|
|
170
191
|
env_path: override env file location; default ~/.config/remoterf-client/.env
|
|
192
|
+
expected_sha256: the lab's CA fingerprint; without it the CA pinned
|
|
193
|
+
by an earlier fetch (REMOTERF_CA_SHA256) must still match.
|
|
171
194
|
"""
|
|
172
195
|
try:
|
|
173
196
|
if not isinstance(port, int):
|
|
174
197
|
port = int(port)
|
|
175
198
|
|
|
199
|
+
if expected_sha256 is not None and not normalize_sha256(expected_sha256):
|
|
200
|
+
print(f"Not a sha256 fingerprint: {expected_sha256!r}", file=sys.stderr)
|
|
201
|
+
return False
|
|
202
|
+
|
|
203
|
+
ep = Path(env_path).expanduser().resolve() if env_path else _default_env_path()
|
|
204
|
+
|
|
176
205
|
# Determine destination path
|
|
177
206
|
if out_path is not None:
|
|
178
207
|
dest = Path(out_path).expanduser().resolve()
|
|
@@ -187,7 +216,6 @@ def fetch_and_save_ca_cert(
|
|
|
187
216
|
if dest.exists() and not overwrite:
|
|
188
217
|
# Still ensure env points to it (helpful for idempotency)
|
|
189
218
|
if write_env:
|
|
190
|
-
ep = Path(env_path).expanduser().resolve() if env_path else _default_env_path()
|
|
191
219
|
_dotenv_set_key(ep, "REMOTERF_CA_CERT", dest.as_posix())
|
|
192
220
|
return True
|
|
193
221
|
|
|
@@ -197,11 +225,26 @@ def fetch_and_save_ca_cert(
|
|
|
197
225
|
if not data or not _looks_like_pem_cert(data):
|
|
198
226
|
return False
|
|
199
227
|
|
|
228
|
+
# The fetch is plain HTTP: trust only a fingerprint from the lab admin,
|
|
229
|
+
# or the one pinned on first use.
|
|
230
|
+
digest = hashlib.sha256(data).hexdigest()
|
|
231
|
+
pinned = _dotenv_get_key(ep, "REMOTERF_CA_SHA256")
|
|
232
|
+
want = normalize_sha256(expected_sha256 if expected_sha256 is not None else pinned)
|
|
233
|
+
if want and digest != want:
|
|
234
|
+
print(
|
|
235
|
+
f"CA fingerprint mismatch: got {digest}, expected {want}.\n"
|
|
236
|
+
"If the lab changed its CA, pass the new fingerprint from the lab admin:\n"
|
|
237
|
+
" remoterf --config --addr <host:port> --ca-sha256 <hex>\n"
|
|
238
|
+
"or reset the local config with: remoterf --config --wipe",
|
|
239
|
+
file=sys.stderr,
|
|
240
|
+
)
|
|
241
|
+
return False
|
|
242
|
+
|
|
200
243
|
dest.write_bytes(data)
|
|
201
244
|
|
|
202
245
|
# Update .env without quotes
|
|
203
246
|
if write_env:
|
|
204
|
-
ep
|
|
247
|
+
_dotenv_set_key(ep, "REMOTERF_CA_SHA256", digest)
|
|
205
248
|
_dotenv_set_key(ep, "REMOTERF_CA_CERT", dest.as_posix())
|
|
206
249
|
|
|
207
250
|
return True
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
from __future__ import annotations
|
|
19
19
|
|
|
20
|
+
import hashlib
|
|
20
21
|
import os
|
|
21
22
|
import socket
|
|
22
23
|
import sys
|
|
@@ -162,13 +163,16 @@ def _print_tos_notice() -> None:
|
|
|
162
163
|
printf(stripped, Sty.DEFAULT)
|
|
163
164
|
|
|
164
165
|
|
|
165
|
-
def _print_config_summary(host: str, grpc_port: int, cert_port: int, ca_out: Path, env_file: Path
|
|
166
|
+
def _print_config_summary(host: str, grpc_port: int, cert_port: int, ca_out: Path, env_file: Path,
|
|
167
|
+
ca_sha256: str = "") -> None:
|
|
166
168
|
_print_separator()
|
|
167
169
|
printf("Configuration Complete!", (Sty.BOLD, Sty.GREEN))
|
|
168
170
|
printf("- Details:", Sty.BOLD)
|
|
169
171
|
printf(" gRPC target: ", (Sty.BOLD, Sty.DEFAULT), f"{host}:{grpc_port}", Sty.CYAN)
|
|
170
172
|
printf(" Cert port : ", (Sty.BOLD, Sty.DEFAULT), f"{host}:{cert_port}", Sty.CYAN)
|
|
171
173
|
printf(" CA cert : ", (Sty.BOLD, Sty.DEFAULT), f"{ca_out}", Sty.GRAY)
|
|
174
|
+
if ca_sha256:
|
|
175
|
+
printf(" CA SHA-256 : ", (Sty.BOLD, Sty.DEFAULT), ca_sha256, Sty.GRAY)
|
|
172
176
|
printf(" Env file : ", (Sty.BOLD, Sty.DEFAULT), f"{env_file}", Sty.GRAY)
|
|
173
177
|
_print_separator()
|
|
174
178
|
|
|
@@ -224,7 +228,7 @@ def require_tos_for_login() -> bool:
|
|
|
224
228
|
remember_tos_agreement()
|
|
225
229
|
return True
|
|
226
230
|
|
|
227
|
-
def configure(host: str, port: int, cert_port: int) -> int:
|
|
231
|
+
def configure(host: str, port: int, cert_port: int, ca_sha256: Optional[str] = None) -> int:
|
|
228
232
|
# Basic validation
|
|
229
233
|
host = (host or "").strip()
|
|
230
234
|
if not host:
|
|
@@ -259,24 +263,33 @@ def configure(host: str, port: int, cert_port: int) -> int:
|
|
|
259
263
|
certs_dir.mkdir(parents=True, exist_ok=True)
|
|
260
264
|
ca_out = certs_dir / f"{profile}.crt"
|
|
261
265
|
|
|
266
|
+
env_file = _env_path()
|
|
262
267
|
fetched_ok = fetch_and_save_ca_cert(
|
|
263
268
|
host,
|
|
264
269
|
cert_port,
|
|
265
270
|
out_path=ca_out,
|
|
266
271
|
timeout_sec=timeout_sec,
|
|
267
272
|
overwrite=overwrite,
|
|
273
|
+
env_path=env_file,
|
|
274
|
+
expected_sha256=ca_sha256,
|
|
268
275
|
)
|
|
269
276
|
if not fetched_ok:
|
|
270
277
|
print(f"Failed to fetch CA cert from {host}:{cert_port}.", file=sys.stderr)
|
|
271
278
|
return 1
|
|
272
279
|
|
|
273
|
-
|
|
274
|
-
|
|
280
|
+
try:
|
|
281
|
+
ca_digest = hashlib.sha256(ca_out.read_bytes()).hexdigest()
|
|
282
|
+
except OSError:
|
|
283
|
+
ca_digest = ""
|
|
284
|
+
env_kv = {
|
|
275
285
|
"REMOTERF_ADDR": f"{host}:{grpc_port}",
|
|
276
286
|
"REMOTERF_CA_CERT": str(ca_out),
|
|
277
287
|
"REMOTERF_PROFILE": profile,
|
|
278
288
|
"REMOTERF_CERT_PORT": str(cert_port),
|
|
279
|
-
}
|
|
289
|
+
}
|
|
290
|
+
if ca_digest:
|
|
291
|
+
env_kv["REMOTERF_CA_SHA256"] = ca_digest # the pin the next -c checks against
|
|
292
|
+
_write_env_kv(env_file, env_kv)
|
|
280
293
|
# This profile is what the "default" home was adopted from. A new address
|
|
281
294
|
# or a re-fetched CA makes that adoption stale (its pin would now refuse
|
|
282
295
|
# this very server), so replace it with this one, the next `-l` target.
|
|
@@ -289,7 +302,7 @@ def configure(host: str, port: int, cert_port: int) -> int:
|
|
|
289
302
|
except Exception: # noqa: BLE001 - never fail configuration over bookkeeping
|
|
290
303
|
pass
|
|
291
304
|
|
|
292
|
-
_print_config_summary(host, grpc_port, cert_port, ca_out, env_file)
|
|
305
|
+
_print_config_summary(host, grpc_port, cert_port, ca_out, env_file, ca_digest)
|
|
293
306
|
|
|
294
307
|
def wipe_config(*, yes: bool = False) -> int:
|
|
295
308
|
"""
|
|
@@ -422,15 +422,7 @@ def _account_command(command):
|
|
|
422
422
|
if command in ('forgot-password', 'reset-password'):
|
|
423
423
|
if not account.is_https_home:
|
|
424
424
|
raise AccountBackendError('Contact the local administrator to reset a password')
|
|
425
|
-
|
|
426
|
-
_note("Forgot password", (Sty.BOLD, Sty.BLUE))
|
|
427
|
-
account.backend.forgot(_ask('Email'))
|
|
428
|
-
_note('If eligible, check your email for a password reset token.', Sty.DEFAULT)
|
|
429
|
-
else:
|
|
430
|
-
_panel("Reset password", [("Set a new password with the emailed reset token.", Sty.DEFAULT), (_PASSWORD_HINT, Sty.GRAY)])
|
|
431
|
-
token = _ask('Password reset token', hidden=True)
|
|
432
|
-
account.backend.reset(token, _password_confirmation(enforce_policy=True))
|
|
433
|
-
_note('Password reset. Log in again.', (Sty.BOLD, Sty.GREEN))
|
|
425
|
+
_note('Reset a RemoteRF Global password from your terminal: remoterf --reset-password', Sty.DEFAULT)
|
|
434
426
|
return False
|
|
435
427
|
if command in ('l', 'login'):
|
|
436
428
|
_note(f"Login to {_home_name()}", (Sty.BOLD, Sty.BLUE))
|
|
@@ -454,7 +446,7 @@ def _account_command(command):
|
|
|
454
446
|
_remember_login()
|
|
455
447
|
_sync_labs()
|
|
456
448
|
return ok
|
|
457
|
-
printf('Choose login or register' + ('
|
|
449
|
+
printf('Choose login or register' + (' or verify.' if account.is_https_home else '.'), Sty.WARNING)
|
|
458
450
|
return False
|
|
459
451
|
|
|
460
452
|
|
|
@@ -510,7 +502,8 @@ def welcome(*, show_banner: bool = True, initial=(), route=None):
|
|
|
510
502
|
else:
|
|
511
503
|
prompt = 'Please login or register to continue. (l/r): '
|
|
512
504
|
if account.is_https_home:
|
|
513
|
-
|
|
505
|
+
printf('Forgot your password? Run: remoterf --reset-password', Sty.GRAY)
|
|
506
|
+
prompt = 'Choose register, verify or login: '
|
|
514
507
|
command = session.prompt(stylize(prompt, Sty.DEFAULT)).strip().lower()
|
|
515
508
|
if command in ('exit', 'quit'):
|
|
516
509
|
return False
|
|
@@ -519,7 +512,7 @@ def welcome(*, show_banner: bool = True, initial=(), route=None):
|
|
|
519
512
|
except (AccountBackendError, ValidationError) as exc:
|
|
520
513
|
_error(exc)
|
|
521
514
|
if command in ('l', 'login') and account.is_https_home and getattr(exc, 'code', None) == 'invalid_credentials':
|
|
522
|
-
printf('Forgot your password? Run: remoterf --reset-
|
|
515
|
+
printf('Forgot your password? Run: remoterf --reset-password', Sty.GRAY)
|
|
523
516
|
queue.clear()
|
|
524
517
|
except (KeyboardInterrupt, EOFError):
|
|
525
518
|
return False
|
|
@@ -609,7 +602,6 @@ def commands():
|
|
|
609
602
|
("'logout'", "Log out and forget the stored login"),
|
|
610
603
|
("'status'", "Show connection and device transport status"),
|
|
611
604
|
("'direct on|off'", "Enable or disable direct device transport"),
|
|
612
|
-
*([("'reset-password'", "Set a new password with an emailed token")] if account.is_https_home else []),
|
|
613
605
|
("'exit' or 'quit'", "Exit"),
|
|
614
606
|
]
|
|
615
607
|
width = max(len(name) for name, _ in rows)
|
|
@@ -1740,12 +1732,12 @@ def run(backend=None, *, register=False, enrollment_code=None, server_label=None
|
|
|
1740
1732
|
completer=command_completer,
|
|
1741
1733
|
)
|
|
1742
1734
|
inpu = inpu.strip()
|
|
1743
|
-
if inpu in ('register', 'verify', 'login'
|
|
1735
|
+
if inpu in ('register', 'verify', 'login'):
|
|
1744
1736
|
authenticated = _account_command(inpu)
|
|
1745
1737
|
if inpu == 'login' and authenticated:
|
|
1746
1738
|
session_line()
|
|
1747
|
-
|
|
1748
|
-
|
|
1739
|
+
elif inpu in ('forgot-password', 'reset-password'):
|
|
1740
|
+
_account_command(inpu)
|
|
1749
1741
|
elif inpu == 'refresh':
|
|
1750
1742
|
if not account.is_https_home:
|
|
1751
1743
|
raise AccountBackendError('Local passwords do not use refresh sessions')
|
|
@@ -154,39 +154,29 @@ def print_help() -> None:
|
|
|
154
154
|
printf(" remoterf -l | --login [target]", Sty.CYAN, " Login: last used, 'global', a home name, or an account (username@deployment)", Sty.DEFAULT)
|
|
155
155
|
printf(" remoterf -r | --register", Sty.CYAN, " Create a RemoteRF Global account", Sty.DEFAULT)
|
|
156
156
|
printf(" remoterf -r --local-only", Sty.CYAN, " Register at a deployment with an enrollment code", Sty.DEFAULT)
|
|
157
|
-
printf(" remoterf --reset-
|
|
157
|
+
printf(" remoterf --reset-password", Sty.CYAN, " Reset a RemoteRF Global password by email", Sty.DEFAULT)
|
|
158
158
|
printf(" remoterf homes", Sty.CYAN, " List saved deployment homes", Sty.DEFAULT)
|
|
159
159
|
printf(" remoterf --remote-admin [lab]", Sty.CYAN, " Open a lab's remote-admin console (-h for more)", Sty.DEFAULT)
|
|
160
160
|
printf(" remoterf -v | --version", Sty.CYAN, " Print version", Sty.DEFAULT)
|
|
161
|
+
printf(" remoterf doctor", Sty.CYAN, " Check this install", Sty.DEFAULT)
|
|
161
162
|
print()
|
|
162
163
|
printf("Config:", (Sty.BOLD, Sty.MAGENTA))
|
|
163
164
|
printf(" remoterf -c | --config [options]", Sty.CYAN)
|
|
164
165
|
printf(" -a, --addr <host:port>", Sty.CYAN, " Set target server", Sty.DEFAULT)
|
|
165
166
|
printf(" --cert-port <port>", Sty.CYAN, " Cert server port (default: grpc port + 1)", Sty.DEFAULT)
|
|
167
|
+
printf(" --ca-sha256 <hex>", Sty.CYAN, " Lab CA fingerprint (default: pin on first use)", Sty.DEFAULT)
|
|
166
168
|
printf(" -w, --wipe", Sty.CYAN, " Delete all local config", Sty.DEFAULT)
|
|
167
169
|
printf(" -y, --yes", Sty.CYAN, " Skip wipe confirmation", Sty.DEFAULT)
|
|
168
170
|
printf(" -r, --register", Sty.CYAN, " Register right after configuring", Sty.DEFAULT)
|
|
169
171
|
print()
|
|
170
172
|
printf(" --account-transport https-json", Sty.CYAN, " Select an HTTPS home on a custom port", Sty.DEFAULT)
|
|
171
173
|
print()
|
|
172
|
-
printf("Scripts and AI agents
|
|
173
|
-
printf(" remoterf
|
|
174
|
-
printf(" remoterf auth status | logout", Sty.CYAN, " The saved login (`remoterf whoami` = auth status)", Sty.DEFAULT)
|
|
175
|
-
printf(" remoterf devices [--deployment D] [--all]", Sty.CYAN, " Devices and their state", Sty.DEFAULT)
|
|
176
|
-
printf(" remoterf slots HANDLE [--days N]", Sty.CYAN, " Free slots on a device", Sty.DEFAULT)
|
|
177
|
-
printf(" remoterf reservations", Sty.CYAN, " Your reservations", Sty.DEFAULT)
|
|
178
|
-
printf(" remoterf reserve HANDLE --start T --end T --confirm", Sty.CYAN, " [--reveal-token]", Sty.DEFAULT)
|
|
179
|
-
printf(" remoterf cancel RESERVATION_ID --confirm", Sty.CYAN)
|
|
180
|
-
printf(" remoterf api HANDLE | example HANDLE --recipe R", Sty.CYAN, " Device API, example script", Sty.DEFAULT)
|
|
181
|
-
printf(" remoterf guide [TOPIC]", Sty.CYAN, " The guide for AI agents", Sty.DEFAULT)
|
|
182
|
-
printf(" remoterf skill install", Sty.CYAN, " Install the guide for Claude, Codex, Gemini", Sty.DEFAULT)
|
|
183
|
-
printf(" remoterf mcp [--allow-reserve] | mcp install", Sty.CYAN, " Local MCP server", Sty.DEFAULT)
|
|
184
|
-
printf(" remoterf doctor", Sty.CYAN, " Check this install", Sty.DEFAULT)
|
|
185
|
-
printf(" Exit codes: 0 ok, 2 usage, 3 login, 4 not found, 5 conflict, 6 permission, 7 unreachable, 8 update remoterf, 130 interrupted", Sty.GRAY)
|
|
174
|
+
printf("Scripts and AI agents:", (Sty.BOLD, Sty.MAGENTA))
|
|
175
|
+
printf(" remoterf guide cli", Sty.CYAN, " Commands for scripts and AI agents", Sty.DEFAULT)
|
|
186
176
|
print()
|
|
187
177
|
printf("Examples:", (Sty.BOLD, Sty.MAGENTA))
|
|
188
178
|
printf(" remoterf --register --local-only", Sty.GREEN, " then: ucla.global.remoterf.net/QEHN7", Sty.GRAY)
|
|
189
|
-
printf(" remoterf --reset-
|
|
179
|
+
printf(" remoterf --reset-password", Sty.GREEN)
|
|
190
180
|
printf(" remoterf --login ucla", Sty.GREEN)
|
|
191
181
|
printf(" remoterf --login global", Sty.GREEN)
|
|
192
182
|
printf(" remoterf --login jdoe@ucla", Sty.GREEN)
|
|
@@ -593,9 +583,9 @@ def main() -> int:
|
|
|
593
583
|
print("remoterf: --register takes no arguments (or '--local-only')", file=sys.stderr)
|
|
594
584
|
return 2
|
|
595
585
|
|
|
596
|
-
if argv[0]
|
|
586
|
+
if argv[0] == "--reset-password":
|
|
597
587
|
if len(argv) > 1:
|
|
598
|
-
print("remoterf: --reset-
|
|
588
|
+
print("remoterf: --reset-password takes no arguments", file=sys.stderr)
|
|
599
589
|
return 2
|
|
600
590
|
return _reset_password()
|
|
601
591
|
|
|
@@ -641,6 +631,7 @@ def main() -> int:
|
|
|
641
631
|
register = False
|
|
642
632
|
account_transport = None
|
|
643
633
|
cert_port_arg = None
|
|
634
|
+
ca_sha256 = None
|
|
644
635
|
|
|
645
636
|
i = 1
|
|
646
637
|
while i < len(argv):
|
|
@@ -674,6 +665,14 @@ def main() -> int:
|
|
|
674
665
|
i += 2
|
|
675
666
|
continue
|
|
676
667
|
|
|
668
|
+
if tok in ("--ca-sha256", "-ca-sha256"):
|
|
669
|
+
if i + 1 >= len(argv):
|
|
670
|
+
print("remoterf: missing required argument after --ca-sha256", file=sys.stderr)
|
|
671
|
+
return 2
|
|
672
|
+
ca_sha256 = argv[i + 1]
|
|
673
|
+
i += 2
|
|
674
|
+
continue
|
|
675
|
+
|
|
677
676
|
if tok in ("--wipe", "-w", "-wipe"):
|
|
678
677
|
wipe = True
|
|
679
678
|
i += 1
|
|
@@ -745,7 +744,8 @@ def main() -> int:
|
|
|
745
744
|
|
|
746
745
|
# configure returns the proper exit code
|
|
747
746
|
cert_port = cert_port_arg if cert_port_arg is not None else port + 1
|
|
748
|
-
|
|
747
|
+
pin = {"ca_sha256": ca_sha256} if ca_sha256 is not None else {}
|
|
748
|
+
result = configure(host, port, cert_port, **pin)
|
|
749
749
|
if result not in (None, 0):
|
|
750
750
|
return int(result)
|
|
751
751
|
select_direct()
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: remoterf
|
|
3
|
-
Version: 2.13.
|
|
3
|
+
Version: 2.13.4
|
|
4
4
|
Summary: A python API to remotely access signal centric hardware. Client-side only! Courtesy of Wireless Lab @ UCLA & Prof. Ian Roberts.
|
|
5
5
|
Author-email: Ethan Ge <84103791+ethange1@users.noreply.github.com>
|
|
6
6
|
License-Expression: GPL-3.0-or-later
|
|
@@ -121,6 +121,26 @@ generic native dispatch, but are not release-qualified as exact UHD overload
|
|
|
121
121
|
parity until the server's UHD 4.10 target-introspection and hardware
|
|
122
122
|
differential gates pass.
|
|
123
123
|
|
|
124
|
+
## Wi-Fi
|
|
125
|
+
|
|
126
|
+
USB Wi-Fi clients are generated from the server's `wifi` schema and installed
|
|
127
|
+
under the matching package name:
|
|
128
|
+
|
|
129
|
+
```python
|
|
130
|
+
from remoterf.drivers import ensure_driver
|
|
131
|
+
|
|
132
|
+
token = "reservation-token"
|
|
133
|
+
ensure_driver(token=token)
|
|
134
|
+
|
|
135
|
+
from remoterf.drivers.wifi import WifiDongle
|
|
136
|
+
|
|
137
|
+
radio = WifiDongle(token)
|
|
138
|
+
print(radio.scan())
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Existing server inventories that use `device_type: wifi_dongle` are accepted
|
|
142
|
+
as `wifi` during upgrade. New inventory entries should use `device_type: wifi`.
|
|
143
|
+
|
|
124
144
|
## RTL-SDR
|
|
125
145
|
|
|
126
146
|
RTL-SDR clients are generated from the server's `rtl_sdr` schema. The machine
|
|
@@ -295,17 +315,17 @@ Welcome to Remote RF Account System.
|
|
|
295
315
|
Please login or register to continue. (l/r):
|
|
296
316
|
```
|
|
297
317
|
|
|
298
|
-
- Once in, input `help` to see all
|
|
318
|
+
- Once in, input `help` to see all available commands.
|
|
299
319
|
|
|
300
320
|
### 3. **Reserve Device**:
|
|
301
321
|
```bash
|
|
302
|
-
getdev # To view all
|
|
322
|
+
getdev # To view all available devices
|
|
303
323
|
|
|
304
324
|
# Note the device ID. You will need this later to reserve said device
|
|
305
325
|
```
|
|
306
326
|
|
|
307
327
|
```bash
|
|
308
|
-
getres # To view times not
|
|
328
|
+
getres # To view times not available
|
|
309
329
|
|
|
310
330
|
# Optionally, you can also view all reservations, and determine a time slot you want a specific device reserved
|
|
311
331
|
```
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
"""`remoterf -c -a host:port` fetches the lab CA over plain HTTP: it must pin
|
|
2
|
+
the fingerprint on first use and refuse a changed CA unless told its digest."""
|
|
3
|
+
|
|
4
|
+
import hashlib
|
|
5
|
+
|
|
6
|
+
import pytest
|
|
7
|
+
|
|
8
|
+
from remoterf.config import cert_fetcher
|
|
9
|
+
from remoterf.config import config as cfg
|
|
10
|
+
|
|
11
|
+
PEM_A = b"-----BEGIN CERTIFICATE-----\nAAAA\n-----END CERTIFICATE-----\n"
|
|
12
|
+
PEM_B = b"-----BEGIN CERTIFICATE-----\nBBBB\n-----END CERTIFICATE-----\n"
|
|
13
|
+
SHA_A = hashlib.sha256(PEM_A).hexdigest()
|
|
14
|
+
SHA_B = hashlib.sha256(PEM_B).hexdigest()
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
@pytest.fixture
|
|
18
|
+
def paths(tmp_path):
|
|
19
|
+
return tmp_path / "ca.crt", tmp_path / ".env"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def _fetch(monkeypatch, paths, served, expected=None):
|
|
23
|
+
monkeypatch.setattr(cert_fetcher, "fetch_ca_bytes", lambda *a, **k: served)
|
|
24
|
+
cert, env = paths
|
|
25
|
+
return cert_fetcher.fetch_and_save_ca_cert(
|
|
26
|
+
"lab.example.org", 61006, out_path=cert, env_path=env, expected_sha256=expected,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def test_fresh_config_pins_the_digest(monkeypatch, paths):
|
|
31
|
+
assert _fetch(monkeypatch, paths, PEM_A)
|
|
32
|
+
cert, env = paths
|
|
33
|
+
assert cert.read_bytes() == PEM_A
|
|
34
|
+
assert f"REMOTERF_CA_SHA256={SHA_A}" in env.read_text()
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
def test_same_cert_again_succeeds(monkeypatch, paths):
|
|
38
|
+
assert _fetch(monkeypatch, paths, PEM_A)
|
|
39
|
+
assert _fetch(monkeypatch, paths, PEM_A)
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
def test_changed_ca_without_flag_is_refused_and_leaves_files(monkeypatch, paths, capsys):
|
|
43
|
+
assert _fetch(monkeypatch, paths, PEM_A)
|
|
44
|
+
cert, env = paths
|
|
45
|
+
before = env.read_text()
|
|
46
|
+
assert not _fetch(monkeypatch, paths, PEM_B)
|
|
47
|
+
assert cert.read_bytes() == PEM_A
|
|
48
|
+
assert env.read_text() == before
|
|
49
|
+
err = capsys.readouterr().err
|
|
50
|
+
assert SHA_A in err and SHA_B in err and "--ca-sha256" in err
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def test_matching_flag_succeeds_and_repins(monkeypatch, paths):
|
|
54
|
+
assert _fetch(monkeypatch, paths, PEM_A)
|
|
55
|
+
assert _fetch(monkeypatch, paths, PEM_B, expected=SHA_B)
|
|
56
|
+
cert, env = paths
|
|
57
|
+
assert cert.read_bytes() == PEM_B
|
|
58
|
+
assert f"REMOTERF_CA_SHA256={SHA_B}" in env.read_text()
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
def test_mismatching_flag_is_refused(monkeypatch, paths):
|
|
62
|
+
assert not _fetch(monkeypatch, paths, PEM_A, expected=SHA_B)
|
|
63
|
+
cert, env = paths
|
|
64
|
+
assert not cert.exists() and not env.exists()
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
@pytest.mark.parametrize("bad", ["", "sha256:", ":", " ", "abc123", "zz" * 32])
|
|
68
|
+
def test_malformed_fingerprint_is_rejected(monkeypatch, paths, bad):
|
|
69
|
+
assert not _fetch(monkeypatch, paths, PEM_A, expected=bad)
|
|
70
|
+
assert not paths[0].exists()
|
|
71
|
+
|
|
72
|
+
|
|
73
|
+
def test_colon_separated_fingerprint_is_accepted(monkeypatch, paths):
|
|
74
|
+
colons = cert_fetcher.sha256_fingerprint_pem(PEM_A).upper()
|
|
75
|
+
assert _fetch(monkeypatch, paths, PEM_A, expected=colons)
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def _configure(monkeypatch, served, **kwargs):
|
|
79
|
+
monkeypatch.setattr(cfg, "_host_resolves", lambda host: True)
|
|
80
|
+
monkeypatch.setattr(cfg, "_confirm_tos", lambda: True)
|
|
81
|
+
monkeypatch.setattr(cert_fetcher, "fetch_ca_bytes", lambda *a, **k: served)
|
|
82
|
+
return cfg.configure("192.168.1.40", 61005, 61006, **kwargs)
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
def test_configure_keeps_the_pin_across_reruns(monkeypatch):
|
|
86
|
+
summaries = []
|
|
87
|
+
monkeypatch.setattr(cfg, "_print_config_summary", lambda *a: summaries.append(a))
|
|
88
|
+
assert _configure(monkeypatch, PEM_A) in (None, 0)
|
|
89
|
+
assert f"REMOTERF_CA_SHA256={SHA_A}" in cfg._env_path().read_text()
|
|
90
|
+
assert summaries[-1][-1] == SHA_A # the fingerprint shown to compare with the lab's
|
|
91
|
+
assert _configure(monkeypatch, PEM_A) in (None, 0)
|
|
92
|
+
assert _configure(monkeypatch, PEM_B) == 1
|
|
93
|
+
assert (cfg._certs_dir() / "default.crt").read_bytes() == PEM_A
|
|
94
|
+
assert _configure(monkeypatch, PEM_B, ca_sha256=SHA_B) in (None, 0)
|
|
95
|
+
assert f"REMOTERF_CA_SHA256={SHA_B}" in cfg._env_path().read_text()
|
|
@@ -183,15 +183,90 @@ def test_reset_password_uses_the_global_email_code_flow(monkeypatch):
|
|
|
183
183
|
backend.close.assert_called_once_with()
|
|
184
184
|
|
|
185
185
|
|
|
186
|
-
def
|
|
186
|
+
def test_reset_password_dispatches_without_an_existing_login(monkeypatch):
|
|
187
187
|
from remoterf import remoterf_cli
|
|
188
188
|
|
|
189
|
-
monkeypatch.setattr("sys.argv", ["remoterf", "--reset-
|
|
189
|
+
monkeypatch.setattr("sys.argv", ["remoterf", "--reset-password"])
|
|
190
190
|
with mock.patch.object(remoterf_cli, "_reset_password", return_value=0) as reset:
|
|
191
191
|
assert remoterf_cli.main() == 0
|
|
192
192
|
reset.assert_called_once_with()
|
|
193
193
|
|
|
194
194
|
|
|
195
|
+
def test_reset_pass_is_an_unknown_command(monkeypatch, capsys):
|
|
196
|
+
from remoterf import remoterf_cli
|
|
197
|
+
|
|
198
|
+
monkeypatch.setattr("sys.argv", ["remoterf", "--reset-pass"])
|
|
199
|
+
with mock.patch.object(remoterf_cli, "_reset_password", return_value=0) as reset:
|
|
200
|
+
assert remoterf_cli.main() == 2
|
|
201
|
+
assert "unknown command" in capsys.readouterr().err
|
|
202
|
+
reset.assert_not_called()
|
|
203
|
+
|
|
204
|
+
|
|
205
|
+
def test_reset_password_takes_no_arguments(monkeypatch, capsys):
|
|
206
|
+
from remoterf import remoterf_cli
|
|
207
|
+
|
|
208
|
+
monkeypatch.setattr("sys.argv", ["remoterf", "--reset-password", "x"])
|
|
209
|
+
with mock.patch.object(remoterf_cli, "_reset_password", return_value=0) as reset:
|
|
210
|
+
assert remoterf_cli.main() == 2
|
|
211
|
+
assert "--reset-password takes no arguments" in capsys.readouterr().err
|
|
212
|
+
reset.assert_not_called()
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
def test_help_names_only_reset_password(monkeypatch):
|
|
216
|
+
from remoterf import remoterf_cli
|
|
217
|
+
|
|
218
|
+
lines = []
|
|
219
|
+
monkeypatch.setattr(remoterf_cli, "printf", lambda *parts: lines.append("".join(parts[::2])))
|
|
220
|
+
remoterf_cli.print_help()
|
|
221
|
+
out = "\n".join(lines)
|
|
222
|
+
assert "remoterf --reset-password" in out
|
|
223
|
+
assert "--reset-pass " not in out
|
|
224
|
+
|
|
225
|
+
|
|
226
|
+
def _reset_command_at(https, command):
|
|
227
|
+
from remoterf.core import app
|
|
228
|
+
|
|
229
|
+
backend = mock.Mock(capabilities={"registration_policy": {}})
|
|
230
|
+
account = mock.Mock(is_https_home=https, backend=backend)
|
|
231
|
+
with mock.patch.object(app, "account", account):
|
|
232
|
+
try:
|
|
233
|
+
return app._account_command(command)
|
|
234
|
+
finally:
|
|
235
|
+
backend.forgot.assert_not_called()
|
|
236
|
+
backend.reset.assert_not_called()
|
|
237
|
+
|
|
238
|
+
|
|
239
|
+
def test_in_app_reset_commands_point_to_the_cli_flag(monkeypatch):
|
|
240
|
+
from remoterf.core import app
|
|
241
|
+
|
|
242
|
+
for command in ("forgot-password", "reset-password"):
|
|
243
|
+
lines = []
|
|
244
|
+
monkeypatch.setattr(app, "printf", lambda *parts: lines.append("".join(parts[::2])))
|
|
245
|
+
assert _reset_command_at(True, command) is False
|
|
246
|
+
assert any("remoterf --reset-password" in line for line in lines)
|
|
247
|
+
|
|
248
|
+
|
|
249
|
+
def test_in_app_reset_commands_at_a_local_home_name_the_administrator():
|
|
250
|
+
import pytest
|
|
251
|
+
from remoterf.deployment.http import AccountBackendError
|
|
252
|
+
|
|
253
|
+
for command in ("forgot-password", "reset-password"):
|
|
254
|
+
with pytest.raises(AccountBackendError, match="local administrator"):
|
|
255
|
+
_reset_command_at(False, command)
|
|
256
|
+
|
|
257
|
+
|
|
258
|
+
def test_session_help_has_no_reset_password_row(monkeypatch):
|
|
259
|
+
from remoterf.core import app
|
|
260
|
+
|
|
261
|
+
lines = []
|
|
262
|
+
monkeypatch.setattr(app, "printf", lambda *parts: lines.append("".join(parts[::2])))
|
|
263
|
+
for https in (True, False):
|
|
264
|
+
with mock.patch.object(app, "account", mock.Mock(is_https_home=https, is_admin=False)):
|
|
265
|
+
app.commands()
|
|
266
|
+
assert any("'logout'" in line for line in lines)
|
|
267
|
+
assert not any("reset-password" in line for line in lines)
|
|
268
|
+
|
|
269
|
+
|
|
195
270
|
def _login_at(home, typed, *, https=False, pending=None):
|
|
196
271
|
from remoterf.core import app
|
|
197
272
|
|
|
@@ -85,7 +85,7 @@ class HostResolvesTests(unittest.TestCase):
|
|
|
85
85
|
class ConfigurePreservesHostnameTests(unittest.TestCase):
|
|
86
86
|
"""`configure()` must store the hostname as configured, never a resolved IP."""
|
|
87
87
|
|
|
88
|
-
def _run_configure(self, host, port=443, cert_port=444):
|
|
88
|
+
def _run_configure(self, host, port=443, cert_port=444, **kwargs):
|
|
89
89
|
written: dict[str, dict[str, str]] = {}
|
|
90
90
|
|
|
91
91
|
def fake_write_env_kv(path, kv):
|
|
@@ -96,10 +96,18 @@ class ConfigurePreservesHostnameTests(unittest.TestCase):
|
|
|
96
96
|
mock.patch.object(config_mod, "fetch_and_save_ca_cert", return_value=True) as fetch, \
|
|
97
97
|
mock.patch.object(config_mod, "_write_env_kv", side_effect=fake_write_env_kv), \
|
|
98
98
|
mock.patch.object(config_mod, "_print_config_summary"):
|
|
99
|
-
config_mod.configure(host, port, cert_port)
|
|
99
|
+
config_mod.configure(host, port, cert_port, **kwargs)
|
|
100
100
|
|
|
101
101
|
return written["kv"], fetch
|
|
102
102
|
|
|
103
|
+
def test_no_fingerprint_by_default(self):
|
|
104
|
+
_, fetch = self._run_configure("192.168.1.20")
|
|
105
|
+
self.assertIsNone(fetch.call_args.kwargs["expected_sha256"])
|
|
106
|
+
|
|
107
|
+
def test_ca_sha256_is_passed_to_the_fetch(self):
|
|
108
|
+
_, fetch = self._run_configure("192.168.1.20", ca_sha256="ab" * 32)
|
|
109
|
+
self.assertEqual(fetch.call_args.kwargs["expected_sha256"], "ab" * 32)
|
|
110
|
+
|
|
103
111
|
def test_hostname_is_preserved_in_saved_config(self):
|
|
104
112
|
kv, fetch = self._run_configure("ucla.global.remoterf.net")
|
|
105
113
|
|
|
@@ -272,7 +272,7 @@ def test_reconfiguring_the_direct_target_replaces_a_stale_default_home(monkeypat
|
|
|
272
272
|
monkeypatch.setattr(cfg, "_host_resolves", lambda host: True)
|
|
273
273
|
monkeypatch.setattr(cfg, "_confirm_tos", lambda: True)
|
|
274
274
|
|
|
275
|
-
def fetch(host, port, *, out_path, timeout_sec, overwrite):
|
|
275
|
+
def fetch(host, port, *, out_path, timeout_sec, overwrite, **_):
|
|
276
276
|
out_path.write_bytes(new_cert)
|
|
277
277
|
return True
|
|
278
278
|
|
|
@@ -297,7 +297,7 @@ def test_configure_keeps_a_custom_cert_port_and_wins_over_other_homes(monkeypatc
|
|
|
297
297
|
monkeypatch.setattr(cfg, "_confirm_tos", lambda: True)
|
|
298
298
|
monkeypatch.setattr(
|
|
299
299
|
cfg, "fetch_and_save_ca_cert",
|
|
300
|
-
lambda host, port, *, out_path, timeout_sec, overwrite: out_path.write_bytes(CERT) or True,
|
|
300
|
+
lambda host, port, *, out_path, timeout_sec, overwrite, **_: out_path.write_bytes(CERT) or True,
|
|
301
301
|
)
|
|
302
302
|
cfg.configure("192.168.1.30", 61005, 7000)
|
|
303
303
|
|
|
@@ -693,7 +693,7 @@ def test_reconfiguring_forgets_the_old_servers_login(monkeypatch):
|
|
|
693
693
|
monkeypatch.setattr(cfg, "_confirm_tos", lambda: True)
|
|
694
694
|
monkeypatch.setattr(
|
|
695
695
|
cfg, "fetch_and_save_ca_cert",
|
|
696
|
-
lambda host, port, *, out_path, timeout_sec, overwrite: out_path.write_bytes(CERT) or True,
|
|
696
|
+
lambda host, port, *, out_path, timeout_sec, overwrite, **_: out_path.write_bytes(CERT) or True,
|
|
697
697
|
)
|
|
698
698
|
cfg.configure("192.168.1.31", 61005, 61006)
|
|
699
699
|
assert homes.recall_login("default") is None
|
|
@@ -57,6 +57,16 @@ class RemoteRFCliTests(unittest.TestCase):
|
|
|
57
57
|
self.assertEqual(remoterf_cli.main(), 0)
|
|
58
58
|
configure.assert_called_once_with("10.0.0.1", 12321, 12322)
|
|
59
59
|
|
|
60
|
+
@mock.patch("remoterf.config.config.configure")
|
|
61
|
+
@mock.patch.object(
|
|
62
|
+
remoterf_cli.sys, "argv", ["remoterf", "-c", "-a", "10.0.0.1:12321", "--ca-sha256", "ab" * 32]
|
|
63
|
+
)
|
|
64
|
+
@mock.patch("remoterf.deployment.state.select_direct")
|
|
65
|
+
def test_config_passes_the_ca_fingerprint(self, _select_direct, configure):
|
|
66
|
+
configure.return_value = 0
|
|
67
|
+
self.assertEqual(remoterf_cli.main(), 0)
|
|
68
|
+
configure.assert_called_once_with("10.0.0.1", 12321, 12322, ca_sha256="ab" * 32)
|
|
69
|
+
|
|
60
70
|
|
|
61
71
|
if __name__ == "__main__":
|
|
62
72
|
unittest.main()
|
|
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
|
{remoterf-2.13.2 → remoterf-2.13.4}/src/remoterf/common/grpc/deployment_capabilities_pb2_grpc.py
RENAMED
|
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
|
|
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
|