RemoteRF 2.13.3__tar.gz → 2.13.5__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 (126) hide show
  1. {remoterf-2.13.3/src/remoterf.egg-info → remoterf-2.13.5}/PKG-INFO +4 -4
  2. {remoterf-2.13.3 → remoterf-2.13.5}/README.md +3 -3
  3. {remoterf-2.13.3 → remoterf-2.13.5}/pyproject.toml +1 -1
  4. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/config/cert_fetcher.py +45 -2
  5. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/config/config.py +19 -6
  6. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/app.py +4 -4
  7. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/remoterf_cli.py +15 -15
  8. {remoterf-2.13.3 → remoterf-2.13.5/src/remoterf.egg-info}/PKG-INFO +4 -4
  9. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf.egg-info/SOURCES.txt +1 -0
  10. remoterf-2.13.5/tests/test_ca_pin.py +95 -0
  11. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_config_address.py +10 -2
  12. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_homes.py +3 -3
  13. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_remoterf_cli.py +10 -0
  14. {remoterf-2.13.3 → remoterf-2.13.5}/LICENSE +0 -0
  15. {remoterf-2.13.3 → remoterf-2.13.5}/setup.cfg +0 -0
  16. {remoterf-2.13.3 → remoterf-2.13.5}/setup.py +0 -0
  17. {remoterf-2.13.3 → remoterf-2.13.5}/src/_remoterf_alias.py +0 -0
  18. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/__init__.py +0 -0
  19. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/admin.py +0 -0
  20. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/agent_cli.py +0 -0
  21. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/agent_docs.py +0 -0
  22. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/__init__.py +0 -0
  23. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/__init__.py +0 -0
  24. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/deployment_capabilities.proto +0 -0
  25. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/deployment_capabilities_pb2.py +0 -0
  26. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/deployment_capabilities_pb2_grpc.py +0 -0
  27. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/grpc.proto +0 -0
  28. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/grpc_pb2.py +0 -0
  29. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/grpc_pb2_grpc.py +0 -0
  30. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/grpc/v2_codec.py +0 -0
  31. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/tos_notice.txt +0 -0
  32. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/utils/__init__.py +0 -0
  33. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/utils/ansi_codes.py +0 -0
  34. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/utils/api_token.py +0 -0
  35. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/utils/banner.py +0 -0
  36. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/utils/list_string.py +0 -0
  37. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/common/utils/process_arg.py +0 -0
  38. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/config/__init__.py +0 -0
  39. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/__init__.py +0 -0
  40. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/acc_login.py +0 -0
  41. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/availability.py +0 -0
  42. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/banner_note.txt +0 -0
  43. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/direct_path.py +0 -0
  44. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/dynamic_v2_transport.py +0 -0
  45. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/grpc_acc.py +0 -0
  46. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/grpc_client.py +0 -0
  47. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/messages.py +0 -0
  48. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/secure_channel.py +0 -0
  49. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/core/v2_errors.py +0 -0
  50. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/data/agent_guide.md +0 -0
  51. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/data/mcp_tools.json +0 -0
  52. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/deployment/__init__.py +0 -0
  53. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/deployment/backend.py +0 -0
  54. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/deployment/direct.py +0 -0
  55. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/deployment/homes.py +0 -0
  56. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/deployment/http.py +0 -0
  57. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/deployment/lanpass.py +0 -0
  58. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/deployment/state.py +0 -0
  59. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/__init__.py +0 -0
  60. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/_virtual.py +0 -0
  61. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/adalm_pluto/__init__.py +0 -0
  62. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/adalm_pluto/adalm_pluto_remote.py +0 -0
  63. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/dynamic_device.py +0 -0
  64. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/dynamic_v2.py +0 -0
  65. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/hackrf/__init__.py +0 -0
  66. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/hackrf/hackrf_remote.py +0 -0
  67. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/rtl_sdr/__init__.py +0 -0
  68. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/rtl_sdr/rtl_sdr_remote.py +0 -0
  69. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/schema_review.py +0 -0
  70. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/sim_sdr/__init__.py +0 -0
  71. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/sim_sdr/sim_sdr_remote.py +0 -0
  72. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/support/__init__.py +0 -0
  73. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/support/ti_mmwave.py +0 -0
  74. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/support/uhd.py +0 -0
  75. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/support/uhd_dsp.py +0 -0
  76. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/support/uhd_v2.py +0 -0
  77. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/ti_mmwave/__init__.py +0 -0
  78. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/ti_mmwave/ti_mmwave_remote.py +0 -0
  79. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/usrp/__init__.py +0 -0
  80. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/usrp/usrp_remote.py +0 -0
  81. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/drivers/usrp/usrp_remote.pyi +0 -0
  82. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/mcp_server.py +0 -0
  83. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/ops.py +0 -0
  84. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf/version.py +0 -0
  85. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf.egg-info/dependency_links.txt +0 -0
  86. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf.egg-info/entry_points.txt +0 -0
  87. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf.egg-info/requires.txt +0 -0
  88. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf.egg-info/top_level.txt +0 -0
  89. {remoterf-2.13.3 → remoterf-2.13.5}/src/remoterf.py +0 -0
  90. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_agent_cli.py +0 -0
  91. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_agent_docs.py +0 -0
  92. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_banner.py +0 -0
  93. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_batch.py +0 -0
  94. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_bundled_drivers.py +0 -0
  95. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_cli_login_fresh.py +0 -0
  96. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_deployment_accounts.py +0 -0
  97. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_device_routes.py +0 -0
  98. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_devices_api.py +0 -0
  99. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_direct_path_fixed.py +0 -0
  100. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_direct_path_global.py +0 -0
  101. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_direct_path_partner.py +0 -0
  102. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_direct_path_race.py +0 -0
  103. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_direct_path_relay.py +0 -0
  104. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_dynamic_device_codegen.py +0 -0
  105. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_dynamic_v2.py +0 -0
  106. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_federated_devices.py +0 -0
  107. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_fetch_idl_fallback.py +0 -0
  108. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_finish_prompt.py +0 -0
  109. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_gate_i_direct_path.py +0 -0
  110. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_grpc_client_target.py +0 -0
  111. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_lan_fallback.py +0 -0
  112. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_mcp_server.py +0 -0
  113. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_messages.py +0 -0
  114. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_native_account_credentials.py +0 -0
  115. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_native_devices.py +0 -0
  116. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_old_import_name.py +0 -0
  117. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_ops.py +0 -0
  118. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_partner_dynamic_v2.py +0 -0
  119. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_pluto_virtual.py +0 -0
  120. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_process_arg.py +0 -0
  121. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_relay_paging.py +0 -0
  122. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_remote_admin.py +0 -0
  123. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_rx_readahead.py +0 -0
  124. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_schema_review.py +0 -0
  125. {remoterf-2.13.3 → remoterf-2.13.5}/tests/test_ti_mmwave.py +0 -0
  126. {remoterf-2.13.3 → remoterf-2.13.5}/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
3
+ Version: 2.13.5
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
@@ -315,17 +315,17 @@ Welcome to Remote RF Account System.
315
315
  Please login or register to continue. (l/r):
316
316
  ```
317
317
 
318
- - Once in, input `help` to see all avaliable commands.
318
+ - Once in, input `help` to see all available commands.
319
319
 
320
320
  ### 3. **Reserve Device**:
321
321
  ```bash
322
- getdev # To view all avaliable devices
322
+ getdev # To view all available devices
323
323
 
324
324
  # Note the device ID. You will need this later to reserve said device
325
325
  ```
326
326
 
327
327
  ```bash
328
- getres # To view times not avaliable
328
+ getres # To view times not available
329
329
 
330
330
  # Optionally, you can also view all reservations, and determine a time slot you want a specific device reserved
331
331
  ```
@@ -288,17 +288,17 @@ Welcome to Remote RF Account System.
288
288
  Please login or register to continue. (l/r):
289
289
  ```
290
290
 
291
- - Once in, input `help` to see all avaliable commands.
291
+ - Once in, input `help` to see all available commands.
292
292
 
293
293
  ### 3. **Reserve Device**:
294
294
  ```bash
295
- getdev # To view all avaliable devices
295
+ getdev # To view all available devices
296
296
 
297
297
  # Note the device ID. You will need this later to reserve said device
298
298
  ```
299
299
 
300
300
  ```bash
301
- getres # To view times not avaliable
301
+ getres # To view times not available
302
302
 
303
303
  # Optionally, you can also view all reservations, and determine a time slot you want a specific device reserved
304
304
  ```
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "remoterf"
7
- version = "2.13.3"
7
+ version = "2.13.5"
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 = Path(env_path).expanduser().resolve() if env_path else _default_env_path()
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) -> None:
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
- env_file = _env_path()
274
- _write_env_kv(env_file, {
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
  """
@@ -165,9 +165,9 @@ def _print_reserved(where, when, token, handle, logged_in_to, install, no_handle
165
165
  rows.append(("Handle ", Sty.BOLD, handle, (Sty.BOLD, Sty.GREEN)))
166
166
  rows.append(())
167
167
  if handle:
168
- rows += [("Token works anywhere, no login needed.", Sty.DEFAULT),
168
+ rows += [("Token Works anywhere, no login needed.", Sty.DEFAULT),
169
169
  (" Keep it safe: it can't be shown again.", Sty.DEFAULT),
170
- (f"Handle works while you're logged in to {logged_in_to}", Sty.DEFAULT),
170
+ (f"Handle Works while you're logged in to {logged_in_to}", Sty.DEFAULT),
171
171
  (" and this reservation is active.", Sty.DEFAULT)]
172
172
  else:
173
173
  rows += [("Works anywhere, no login needed.", Sty.DEFAULT),
@@ -1453,7 +1453,7 @@ def interactive_reserve_next_days(block_minutes=60):
1453
1453
 
1454
1454
  # --- Display the available slots, using 0-based index ---
1455
1455
  print()
1456
- printf("Available time slots for device ", Sty.BOLD, f"{chosen_device_id}", Sty.MAGENTA, f" over the next {num_days} days:", Sty.DEFAULT)
1456
+ printf("Available time slots for device ", Sty.BOLD, f"{chosen_device_id}", Sty.MAGENTA, f" over the next {num_days} days (your time, {available_slots[0][1][0].astimezone():%Z}):", Sty.DEFAULT)
1457
1457
  last_day = None
1458
1458
  for idx, (day, slot) in enumerate(available_slots):
1459
1459
  slot_start_str = slot[0].strftime('%I:%M %p')
@@ -1540,7 +1540,7 @@ def _pick_slot_and_reserve(chosen_device_id, chosen_device_name, block_minutes,
1540
1540
 
1541
1541
  print()
1542
1542
  index_width = len(str(len(available_slots) - 1))
1543
- rows = [(f"{device_label}", Sty.MAGENTA, f" {block_minutes} min blocks, next {num_days} days", Sty.GRAY)]
1543
+ rows = [(f"{device_label}", Sty.MAGENTA, f" {block_minutes} min blocks, next {num_days} days (your time, {available_slots[0][1][0].astimezone():%Z})", Sty.GRAY)]
1544
1544
  last_day = None
1545
1545
  for idx, (day, slot) in enumerate(available_slots):
1546
1546
  slot_start_str = slot[0].strftime("%I:%M %p")
@@ -158,31 +158,21 @@ def print_help() -> None:
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 (no prompts; --json prints JSON on stdout):", (Sty.BOLD, Sty.MAGENTA))
173
- printf(" remoterf auth login --user NAME --password-stdin", Sty.CYAN, " [--home global|DEPLOYMENT] [--accept-tos]", Sty.DEFAULT)
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)
@@ -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
- result = configure(host, port, cert_port)
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
3
+ Version: 2.13.5
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
@@ -315,17 +315,17 @@ Welcome to Remote RF Account System.
315
315
  Please login or register to continue. (l/r):
316
316
  ```
317
317
 
318
- - Once in, input `help` to see all avaliable commands.
318
+ - Once in, input `help` to see all available commands.
319
319
 
320
320
  ### 3. **Reserve Device**:
321
321
  ```bash
322
- getdev # To view all avaliable devices
322
+ getdev # To view all available devices
323
323
 
324
324
  # Note the device ID. You will need this later to reserve said device
325
325
  ```
326
326
 
327
327
  ```bash
328
- getres # To view times not avaliable
328
+ getres # To view times not available
329
329
 
330
330
  # Optionally, you can also view all reservations, and determine a time slot you want a specific device reserved
331
331
  ```
@@ -86,6 +86,7 @@ tests/test_agent_docs.py
86
86
  tests/test_banner.py
87
87
  tests/test_batch.py
88
88
  tests/test_bundled_drivers.py
89
+ tests/test_ca_pin.py
89
90
  tests/test_cli_login_fresh.py
90
91
  tests/test_config_address.py
91
92
  tests/test_deployment_accounts.py
@@ -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()
@@ -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