RemoteRF 0.0.7.46__tar.gz → 0.0.7.47__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 (41) hide show
  1. {remoterf-0.0.7.46/src/remoteRF.egg-info → remoterf-0.0.7.47}/PKG-INFO +2 -1
  2. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/setup.py +4 -3
  3. remoterf-0.0.7.47/src/remoteRF/config/cert_fetcher.py +140 -0
  4. remoterf-0.0.7.47/src/remoteRF/config/config_cli.py +134 -0
  5. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/core/app.py +34 -2
  6. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/core/grpc_acc.py +8 -1
  7. remoterf-0.0.7.47/src/remoteRF/core/grpc_client.py +320 -0
  8. {remoterf-0.0.7.46 → remoterf-0.0.7.47/src/remoteRF.egg-info}/PKG-INFO +2 -1
  9. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF.egg-info/SOURCES.txt +3 -7
  10. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF.egg-info/entry_points.txt +1 -0
  11. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF.egg-info/requires.txt +1 -0
  12. remoterf-0.0.7.46/src/remoteRF/core/certs/ca.crt +0 -32
  13. remoterf-0.0.7.46/src/remoteRF/core/certs/ca.key +0 -52
  14. remoterf-0.0.7.46/src/remoteRF/core/certs/cert.pem +0 -19
  15. remoterf-0.0.7.46/src/remoteRF/core/certs/key.pem +0 -28
  16. remoterf-0.0.7.46/src/remoteRF/core/certs/server.crt +0 -19
  17. remoterf-0.0.7.46/src/remoteRF/core/certs/server.key +0 -28
  18. remoterf-0.0.7.46/src/remoteRF/core/grpc_client.py +0 -100
  19. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/LICENSE +0 -0
  20. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/MANIFEST.in +0 -0
  21. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/README.md +0 -0
  22. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/setup.cfg +0 -0
  23. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/__init__.py +0 -0
  24. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/__init__.py +0 -0
  25. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/grpc/__init__.py +0 -0
  26. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/grpc/grpc_pb2.py +0 -0
  27. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/grpc/grpc_pb2_grpc.py +0 -0
  28. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/utils/__init__.py +0 -0
  29. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/utils/ansi_codes.py +0 -0
  30. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/utils/api_token.py +0 -0
  31. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/utils/list_string.py +0 -0
  32. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/common/utils/process_arg.py +0 -0
  33. {remoterf-0.0.7.46/src/remoteRF/core/certs → remoterf-0.0.7.47/src/remoteRF/config}/__init__.py +0 -0
  34. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/core/__init__.py +0 -0
  35. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/core/acc_login.py +0 -0
  36. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/core/version.py +0 -0
  37. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/drivers/__init__.py +0 -0
  38. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/drivers/adalm_pluto/__init__.py +0 -0
  39. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF/drivers/adalm_pluto/pluto_remote.py +0 -0
  40. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF.egg-info/dependency_links.txt +0 -0
  41. {remoterf-0.0.7.46 → remoterf-0.0.7.47}/src/remoteRF.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: remoterf
3
- Version: 0.0.7.46
3
+ Version: 0.0.7.47
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: Ethan Ge
6
6
  Author-email: ethoGalaxy@gmail.com
@@ -14,6 +14,7 @@ Requires-Dist: protobuf<6.0.0,>=5.0.0
14
14
  Requires-Dist: numpy
15
15
  Requires-Dist: prompt_toolkit
16
16
  Requires-Dist: python-dotenv
17
+ Requires-Dist: prompt-toolkit
17
18
  Dynamic: author
18
19
  Dynamic: author-email
19
20
  Dynamic: classifier
@@ -6,7 +6,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
6
6
 
7
7
  setup(
8
8
  name="remoterf",
9
- version="0.0.7.46",
9
+ version="0.0.7.47",
10
10
  author="Ethan Ge",
11
11
  author_email="ethoGalaxy@gmail.com",
12
12
  description="A python API to remotely access signal centric hardware. Client-side only! Courtesy of Wireless Lab @ UCLA & Prof. Ian Roberts.",
@@ -17,7 +17,7 @@ setup(
17
17
  license_file='MIT',
18
18
  include_package_data=True, # Includes files specified in MANIFEST.in
19
19
  install_requires=[
20
- "grpcio==1.71.0", "protobuf>=5.0.0,<6.0.0", "numpy", "prompt_toolkit", "python-dotenv"
20
+ "grpcio==1.71.0", "protobuf>=5.0.0,<6.0.0", "numpy", "prompt_toolkit", "python-dotenv", "prompt-toolkit"
21
21
  ],
22
22
  classifiers=[
23
23
  "Programming Language :: Python :: 3",
@@ -28,7 +28,8 @@ setup(
28
28
  entry_points={
29
29
  'console_scripts': [
30
30
  'remoterf-login=remoteRF.core.acc_login:main',
31
- 'remoterf-v=remoteRF.core.version:main'
31
+ 'remoterf-v=remoteRF.core.version:main',
32
+ 'remoterf-config=remoteRF.config.config_cli:main',
32
33
  ],
33
34
  },
34
35
  )
@@ -0,0 +1,140 @@
1
+ # cert_fetcher.py
2
+ """
3
+ RemoteRF Client-Side Cert Fetcher (bootstrap)
4
+
5
+ Purpose:
6
+ - Fetch the public CA certificate (ca.crt) from a server's bootstrap endpoint
7
+ (your cert_provider) and save it locally for later use in:
8
+ grpc.ssl_channel_credentials(root_certificates=ca_bytes)
9
+
10
+ Security note (TOFU):
11
+ - This fetch is typically done over plaintext HTTP (or raw TCP). The CA cert is public,
12
+ but authenticity is not guaranteed on first fetch. If you want TOFU done "right",
13
+ you should display the SHA256 fingerprint and require user confirmation elsewhere.
14
+ This module focuses only on: fetch + save + return success.
15
+
16
+ Behavior:
17
+ - Attempts HTTP GET first: http://{host}:{port}/ca.crt
18
+ - If HTTP fails, falls back to raw TCP (reads until EOF).
19
+ - Saves to a per-profile file under ~/.config/remoterf/certs/ by default.
20
+
21
+ Exported API:
22
+ - fetch_and_save_ca_cert(host, port, *, out_path=None, profile=None, timeout_sec=3.0) -> bool
23
+ """
24
+
25
+ from __future__ import annotations
26
+
27
+ import hashlib
28
+ import os
29
+ import socket
30
+ import urllib.request
31
+ from pathlib import Path
32
+ from typing import Optional
33
+
34
+
35
+ CERT_FILENAME_DEFAULT = "ca.crt"
36
+
37
+
38
+ def _default_config_dir() -> Path:
39
+ # Cross-platform-ish default; adjust if you already have a standard in your project.
40
+ # Linux: ~/.config/remoterf
41
+ # macOS: also acceptable; if you want Apple-standard, use ~/Library/Application Support/remoterf
42
+ base = Path(os.path.expanduser("~")) / ".config" / "remoterf"
43
+ return base
44
+
45
+
46
+ def _ensure_parent_dir(p: Path) -> None:
47
+ p.parent.mkdir(parents=True, exist_ok=True)
48
+
49
+
50
+ def _looks_like_pem_cert(data: bytes) -> bool:
51
+ return b"BEGIN CERTIFICATE" in data and b"END CERTIFICATE" in data
52
+
53
+
54
+ def sha256_fingerprint_pem(pem_bytes: bytes) -> str:
55
+ h = hashlib.sha256(pem_bytes).hexdigest()
56
+ return ":".join(h[i:i+2] for i in range(0, len(h), 2))
57
+
58
+
59
+ def _fetch_http(host: str, port: int, timeout_sec: float) -> bytes:
60
+ url = f"http://{host}:{port}/ca.crt"
61
+ req = urllib.request.Request(url, method="GET")
62
+ with urllib.request.urlopen(req, timeout=timeout_sec) as resp:
63
+ data = resp.read()
64
+ return data
65
+
66
+
67
+ def _fetch_raw_tcp(host: str, port: int, timeout_sec: float) -> bytes:
68
+ chunks: list[bytes] = []
69
+ with socket.create_connection((host, port), timeout=timeout_sec) as s:
70
+ s.settimeout(timeout_sec)
71
+ while True:
72
+ try:
73
+ b = s.recv(4096)
74
+ except socket.timeout:
75
+ break
76
+ if not b:
77
+ break
78
+ chunks.append(b)
79
+ return b"".join(chunks)
80
+
81
+
82
+ def fetch_and_save_ca_cert(
83
+ host: str,
84
+ port: int,
85
+ *,
86
+ out_path: Optional[str | Path] = None,
87
+ profile: Optional[str] = None,
88
+ timeout_sec: float = 3.0,
89
+ overwrite: bool = True,
90
+ ) -> bool:
91
+ """
92
+ Fetch CA cert from the server bootstrap endpoint and save it to disk.
93
+
94
+ Args:
95
+ host: server host/ip running cert_provider
96
+ port: cert_provider port (NOT the TLS gRPC port)
97
+ out_path: explicit output path (overrides profile/default location)
98
+ profile: if provided, saves as ~/.config/remoterf/certs/<profile>.crt
99
+ timeout_sec: network timeout
100
+ overwrite: whether to overwrite existing file
101
+
102
+ Returns:
103
+ True on success, False on any failure.
104
+ """
105
+ try:
106
+ if not isinstance(port, int):
107
+ port = int(port)
108
+
109
+ # Determine destination path
110
+ if out_path is not None:
111
+ dest = Path(out_path).expanduser().resolve()
112
+ else:
113
+ cfg = _default_config_dir()
114
+ certs_dir = cfg / "certs"
115
+ name = f"{profile}.crt" if profile else CERT_FILENAME_DEFAULT
116
+ dest = certs_dir / name
117
+
118
+ _ensure_parent_dir(dest)
119
+
120
+ if dest.exists() and not overwrite:
121
+ return True # already present, treat as success
122
+
123
+ # Fetch (HTTP first, then raw TCP fallback)
124
+ data = b""
125
+ try:
126
+ data = _fetch_http(host, port, timeout_sec)
127
+ except Exception:
128
+ data = _fetch_raw_tcp(host, port, timeout_sec)
129
+
130
+ if not data or not _looks_like_pem_cert(data):
131
+ return False
132
+
133
+ # Save
134
+ dest.write_bytes(data)
135
+
136
+ # Optional: you may want to return/print fingerprint, but requested API is bool.
137
+ return True
138
+
139
+ except Exception:
140
+ return False
@@ -0,0 +1,134 @@
1
+ # src/remoteRF/core/remoterf_config.py
2
+
3
+ from __future__ import annotations
4
+
5
+ import argparse
6
+ import os
7
+ import sys
8
+ from pathlib import Path
9
+ from typing import Tuple
10
+
11
+ from .cert_fetcher import fetch_and_save_ca_cert # your earlier module
12
+
13
+ # -----------------------------
14
+ # Local config locations
15
+ # -----------------------------
16
+ def _config_root() -> Path:
17
+ # Keep it simple and consistent with earlier suggestions.
18
+ return Path(os.path.expanduser("~")) / ".config" / "remoterf"
19
+
20
+ def _env_path() -> Path:
21
+ return _config_root() / ".env"
22
+
23
+ def _certs_dir() -> Path:
24
+ return _config_root() / "certs"
25
+
26
+ def _parse_hostport(s: str) -> Tuple[str, int]:
27
+ s = s.strip()
28
+ if "://" in s:
29
+ s = s.split("://", 1)[1]
30
+
31
+ if ":" not in s:
32
+ raise ValueError("Expected format host:port")
33
+
34
+ host, port_str = s.rsplit(":", 1)
35
+ host = host.strip()
36
+ port = int(port_str.strip())
37
+ if not host:
38
+ raise ValueError("Host is empty")
39
+ if port <= 0 or port > 65535:
40
+ raise ValueError("Port out of range")
41
+ return host, port
42
+
43
+
44
+ def _write_env_kv(path: Path, kv: dict[str, str]) -> None:
45
+ """
46
+ Writes/overwrites a simple dotenv-style file.
47
+ (We overwrite the whole file for simplicity and correctness.)
48
+ """
49
+ path.parent.mkdir(parents=True, exist_ok=True)
50
+ lines = []
51
+ for k, v in kv.items():
52
+ # Quote only if needed; keep simple and safe.
53
+ if any(c.isspace() for c in v) or any(c in v for c in ['"', "'"]):
54
+ v = v.replace('"', '\\"')
55
+ lines.append(f'{k}="{v}"')
56
+ else:
57
+ lines.append(f"{k}={v}")
58
+ path.write_text("\n".join(lines) + "\n", encoding="utf-8")
59
+
60
+ def main() -> None:
61
+ import argparse
62
+ import sys
63
+
64
+ parser = argparse.ArgumentParser(
65
+ prog="remoterf-config",
66
+ add_help=True,
67
+ formatter_class=argparse.RawTextHelpFormatter,
68
+ description=(
69
+ "Configure RemoteRF to talk to a server.\n"
70
+ "Fetches the server CA certificate and saves the gRPC target locally."
71
+ ),
72
+ )
73
+
74
+ parser.add_argument(
75
+ "addr",
76
+ nargs="?",
77
+ help="Server address in host:port form. Example: 164.67.195.207:61005",
78
+ )
79
+
80
+ args = parser.parse_args()
81
+
82
+ if not args.addr:
83
+ print(
84
+ "\nError: missing required argument: host:port\n\n"
85
+ "Usage:\n"
86
+ " remoterf-config <host:port>\n\n"
87
+ "Example:\n"
88
+ " remoterf-config 164.67.195.207:61005\n"
89
+ )
90
+ sys.exit(2)
91
+
92
+ try:
93
+ host, grpc_port = _parse_hostport(args.addr)
94
+ except Exception as e:
95
+ print(f"Error: invalid addr '{args.addr}': {e}", file=sys.stderr)
96
+ sys.exit(2)
97
+
98
+ # Single-arg policy
99
+ cert_port = grpc_port + 1 # cert-provider convention
100
+ profile = "default"
101
+ timeout_sec = 3.0
102
+ overwrite = True
103
+
104
+ certs_dir = _certs_dir()
105
+ certs_dir.mkdir(parents=True, exist_ok=True)
106
+ ca_out = certs_dir / f"{profile}.crt"
107
+
108
+ fetched_ok = fetch_and_save_ca_cert(
109
+ host,
110
+ cert_port,
111
+ out_path=ca_out,
112
+ timeout_sec=timeout_sec,
113
+ overwrite=overwrite,
114
+ )
115
+
116
+ if not fetched_ok:
117
+ print(f"Failed to fetch CA cert from {host}:{cert_port}.", file=sys.stderr)
118
+ sys.exit(1)
119
+
120
+ env_file = _env_path()
121
+ _write_env_kv(env_file, {
122
+ "REMOTERF_ADDR": f"{host}:{grpc_port}",
123
+ "REMOTERF_CA_CERT": str(ca_out),
124
+ "REMOTERF_PROFILE": profile,
125
+ })
126
+
127
+ print("RemoteRF configured successfully.")
128
+ print(f" gRPC target : {host}:{grpc_port}")
129
+ print(f" cert port : {host}:{cert_port}")
130
+ print(f" CA cert : {ca_out}")
131
+ print(f" env file : {env_file}")
132
+
133
+ if __name__ == "__main__":
134
+ main()
@@ -1,3 +1,4 @@
1
+ from remoteRF.core.grpc_client import handle_admin_command
1
2
  from . import *
2
3
  from ..common.utils import *
3
4
 
@@ -30,6 +31,7 @@ def welcome():
30
31
 
31
32
  account.password = password
32
33
  account.email = input("Email: ") # TODO: Email verification.
34
+ account.enrollment_code = input("Enrollment Code: ")
33
35
  # check if login was valid
34
36
  os.system('cls' if os.name == 'nt' else 'clear')
35
37
 
@@ -59,6 +61,7 @@ def commands():
59
61
  printf("'getdev' ", Sty.MAGENTA, " : View devices", Sty.DEFAULT)
60
62
  printf("'help' or 'h' ", Sty.MAGENTA, " : Show this help message", Sty.DEFAULT)
61
63
  printf("'perms' ", Sty.MAGENTA, " : View permissions", Sty.DEFAULT)
64
+ printf("'enroll' ", Sty.MAGENTA, " : Enroll with an enrollment code", Sty.DEFAULT)
62
65
  printf("'exit' or 'quit' ", Sty.MAGENTA, ": Exit", Sty.DEFAULT)
63
66
  printf("'getres' ", Sty.MAGENTA, " : View all reservations", Sty.DEFAULT)
64
67
  printf("'myres' ", Sty.MAGENTA, " : View my reservations", Sty.DEFAULT)
@@ -66,8 +69,20 @@ def commands():
66
69
  printf("'resdev' ", Sty.MAGENTA, " : Reserve a device", Sty.DEFAULT)
67
70
  # printf("'resdev -n' ", Sty.MAGENTA, "- naive reserve device", Sty.DEFAULT)
68
71
  # printf("'resdev s' ", Sty.MAGENTA, "- Reserve a Device (by single date)", Sty.DEFAULT)
69
- # check if user is admin
70
- # if account.get_perms().results['UC'] == 'Admin':
72
+
73
+ if account.is_admin:
74
+ print()
75
+ printf("Admin Commands:", Sty.BOLD)
76
+ printf("'admin printa' ", Sty.MAGENTA, " : Print all accounts", Sty.DEFAULT)
77
+ printf("'admin printr' ", Sty.MAGENTA, " : Print all reservations", Sty.DEFAULT)
78
+ printf("'admin printp' ", Sty.MAGENTA, " : Print all perms", Sty.DEFAULT)
79
+ printf("'admin printd' ", Sty.MAGENTA, " : Print all devices", Sty.DEFAULT)
80
+ printf("'admin rm a <username>' ", Sty.MAGENTA, " : Remove one account", Sty.DEFAULT)
81
+ printf("'admin rm aa' ", Sty.MAGENTA, " : Remove all accounts", Sty.DEFAULT)
82
+ printf("'admin rm ar' ", Sty.MAGENTA, " : Remove all reservations", Sty.DEFAULT)
83
+ # If you expose set_account remotely:
84
+ printf("'admin setacc <username> <U|P|A> [args...]' ", Sty.MAGENTA, " : Set perms", Sty.DEFAULT)
85
+
71
86
 
72
87
  def clear():
73
88
  os.system('cls' if os.name == 'nt' else 'clear')
@@ -267,6 +282,18 @@ def perms():
267
282
  printf(f'No restrictions on reservation count or duration.', Sty.DEFAULT)
268
283
  else:
269
284
  printf(f"Error: Unknown permission level {results[0]}", Sty.BRIGHT_RED)
285
+
286
+ def enroll():
287
+ code = session.prompt(stylize("Enter your enrollment code: ", Sty.DEFAULT))
288
+ account.enrollment_code = code
289
+ data = account.set_enroll()
290
+
291
+ if 'ace' in data.results:
292
+ print(f"Error: {unmap_arg(data.results['ace'])}")
293
+ return
294
+ else:
295
+ # todo: print out specifics, like group name (ie: successfully enrolled in ECE 132A)
296
+ printf("Enrollment successful.", Sty.BOLD_GREEN)
270
297
 
271
298
  # New block scheduling
272
299
 
@@ -484,6 +511,8 @@ while True:
484
511
  commands()
485
512
  elif inpu == "perms":
486
513
  perms()
514
+ elif inpu == "enroll":
515
+ enroll()
487
516
  elif inpu == "quit" or inpu == "exit":
488
517
  break
489
518
  elif inpu == "getres":
@@ -496,10 +525,13 @@ while True:
496
525
  interactive_reserve_next_days(block_minutes=30)
497
526
  elif inpu == 'cancelres':
498
527
  cancel_my_reservation()
528
+
499
529
  elif inpu == 'resdev -n':
500
530
  # check if user is admin
501
531
  # if account.get_perms().results['UC'] == 'Admin':
502
532
  reserve()
533
+ elif account.is_admin and inpu.strip().startswith("admin"):
534
+ handle_admin_command(inpu)
503
535
  else:
504
536
  print(f"Unknown command: {inpu}")
505
537
  except KeyboardInterrupt:
@@ -1,3 +1,4 @@
1
+ import ast
1
2
  from .grpc_client import rpc_client
2
3
  from ..common.utils import *
3
4
 
@@ -8,9 +9,10 @@ class RemoteRFAccount:
8
9
  self.username = username
9
10
  self.password = password
10
11
  self.email = email
12
+ self.enrollment_code = ""
11
13
 
12
14
  def create_user(self):
13
- response = rpc_client(function_name="ACC:create_user", args={"un":map_arg(self.username), "pw":map_arg(self.password), "em":map_arg(self.email)})
15
+ response = rpc_client(function_name="ACC:create_user", args={"un":map_arg(self.username), "pw":map_arg(self.password), "em":map_arg(self.email), "ec":map_arg(self.enrollment_code)})
14
16
  if 'UC' in response.results:
15
17
  print(f'User {unmap_arg(response.results["UC"])} successfully created.')
16
18
  return True
@@ -24,6 +26,8 @@ class RemoteRFAccount:
24
26
  response = rpc_client(function_name="ACC:login", args={"un":map_arg(username), "pw":map_arg(password)})
25
27
  if 'UC' in response.results:
26
28
  print(f'User {unmap_arg(response.results["UC"])} successful login.')
29
+
30
+ self.is_admin = (ast.literal_eval(unmap_arg(self.get_perms().results['UC']))[0][0] == 'Admin')
27
31
  return True
28
32
  elif 'UE' in response.results:
29
33
  print(f'Error: {unmap_arg(response.results["UE"])}')
@@ -49,4 +53,7 @@ class RemoteRFAccount:
49
53
  def get_perms(self):
50
54
  return rpc_client(function_name='ACC:get_perms', args={"un":map_arg(self.username), "pw":map_arg(self.password)})
51
55
 
56
+ def set_enroll(self):
57
+ return rpc_client(function_name='ACC:set_enroll', args={"un":map_arg(self.username), "pw":map_arg(self.password), "ec":map_arg(self.enrollment_code)})
58
+
52
59
 
@@ -0,0 +1,320 @@
1
+ import socket
2
+ import getpass
3
+ from pathlib import Path
4
+ import os
5
+ from dotenv import load_dotenv
6
+
7
+ import grpc
8
+ from ..common.grpc import grpc_pb2
9
+ from ..common.grpc import grpc_pb2_grpc
10
+ from ..common.utils import *
11
+
12
+ load_dotenv(Path.home() / ".config" / "remoterf" / ".env")
13
+ addr = os.getenv("REMOTERF_ADDR") # "host:port"
14
+ ca_path = os.getenv("REMOTERF_CA_CERT") # path to saved CA cert
15
+
16
+ options = [
17
+ ('grpc.max_send_message_length', 100 * 1024 * 1024),
18
+ ('grpc.max_receive_message_length', 100 * 1024 * 1024),
19
+ ]
20
+
21
+ # Server.crt
22
+ certs_path = Path(ca_path).expanduser().resolve()
23
+ with certs_path.open('rb') as f:
24
+ trusted_certs = f.read()
25
+
26
+ credentials = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
27
+ channel = grpc.secure_channel(addr, credentials, options=options)
28
+ stub = grpc_pb2_grpc.GenericRPCStub(channel)
29
+
30
+ tcp_calls = 0
31
+
32
+ def get_tcp_calls():
33
+ return tcp_calls
34
+
35
+ def rpc_client(*, function_name, args):
36
+ global tcp_calls
37
+ tcp_calls += 1
38
+ # print(tcp_calls)
39
+ # if not is_connected:
40
+ # response = rpc_client(function_name="UserLogin", args={"username": grpc_pb2.Argument(string_value=input("Username: ")), "password": grpc_pb2.Argument(string_value=getpass.getpass("Password: ")), "client_ip": grpc_pb2.Argument(string_value=local_ip)})
41
+ # if (response.results['status'].string_value == 'Success'):
42
+ # print("Login successful.")
43
+ # is_connected = True
44
+
45
+ # TODO: Handle user login
46
+
47
+ # print(f"Opening connection to {server_ip}:{server_port}")
48
+
49
+ # TODO: Handle Errors
50
+
51
+ # print(f"Calling function: {function_name}")
52
+ response = stub.Call(grpc_pb2.GenericRPCRequest(function_name=function_name, args=args))
53
+
54
+ if 'a' in response.results:
55
+ print(f"Error: {unmap_arg(response.results['a'])}")
56
+ exit()
57
+
58
+ if 'UE' in response.results:
59
+ print(f"UserError: {unmap_arg(response.results['UE'])}")
60
+ input("Hit enter to continue...")
61
+
62
+ if 'Message' in response.results:
63
+ print(f"{unmap_arg(response.results['Message'])}")
64
+
65
+
66
+ return response
67
+
68
+ #region Example Usage
69
+
70
+ # if __name__ == '__main__':
71
+ # args={
72
+ # "key1": grpc_pb2.Argument(string_value="Hello"),
73
+ # "key2": grpc_pb2.Argument(int32_value=123),
74
+ # "key3": grpc_pb2.Argument(float_value=4.56),
75
+ # "key4": grpc_pb2.Argument(bool_value=True),
76
+ # "client_ip": grpc_pb2.Argument(string_value=local_ip)
77
+ # }
78
+
79
+ # response = rpc_client(function_name="echo", args=args)
80
+
81
+ # if 'client_ip' in response.results:
82
+ # del response.results['client_ip']
83
+
84
+ # # Print results
85
+ # print("Received response:")
86
+ # for key, arg in response.results.items():
87
+ # # Decode the oneof fields
88
+ # if arg.HasField('string_value'):
89
+ # value = arg.string_value
90
+ # elif arg.HasField('int32_value'):
91
+ # value = arg.int32_value
92
+ # elif arg.HasField('float_value'):
93
+ # value = arg.float_value
94
+ # elif arg.HasField('bool_value'):
95
+ # value = arg.bool_value
96
+ # else:
97
+ # value = "Undefined"
98
+
99
+ # print(f"{key}: {value}")
100
+
101
+ #endregion
102
+
103
+ from typing import Any, Dict, Optional
104
+
105
+ def handle_admin_command(inpu: str):
106
+ """
107
+ Parses commands like:
108
+ admin help
109
+ admin printa | printr | printp | printd
110
+ admin rm aa | rm ar | rm a <username>
111
+ admin setacc <username> <U|P|A> [devices=1,2,3] [max_res=5] [max_time=1800]
112
+
113
+ Requires account.is_admin == True (client-side gate). Server still enforces.
114
+ """
115
+ if not getattr(account, "is_admin", False):
116
+ print("Access denied: you are not an Admin.")
117
+ return
118
+
119
+ tokens = (inpu or "").strip().split()
120
+ if len(tokens) < 2 or tokens[0].lower() != "admin":
121
+ print("Usage: admin <command>. Try: admin help")
122
+ return
123
+
124
+ cmd = tokens[1].lower()
125
+
126
+ def call_admin(fn: str, extra: dict | None = None):
127
+ return remote_admin_rpc_client(
128
+ function_name=fn,
129
+ auth_un=account.username,
130
+ auth_pw=account.password,
131
+ args=extra or {},
132
+ print_result=True,
133
+ )
134
+
135
+ if cmd in ("help", "h"):
136
+ print("Admin commands:")
137
+ print(" admin printa - Print all accounts")
138
+ print(" admin printr - Print all reservations")
139
+ print(" admin printp - Print all perms")
140
+ print(" admin printd - Print all devices")
141
+ print(" admin rm aa - Remove all accounts")
142
+ print(" admin rm ar - Remove all reservations")
143
+ print(" admin rm a <username> - Remove one account")
144
+ print(" admin setacc <u> <U|P|A> [devices=1,2] [max_res=3] [max_time=1800]")
145
+ return
146
+
147
+ # ----- print* -----
148
+ if cmd in ("printa", "print_accounts", "print_all_accounts"):
149
+ call_admin("print_all_accounts")
150
+ return
151
+
152
+ if cmd in ("printr", "print_res", "print_all_reservations"):
153
+ call_admin("print_all_reservations")
154
+ return
155
+
156
+ if cmd in ("printp", "print_perms", "print_all_perms"):
157
+ call_admin("print_all_perms")
158
+ return
159
+
160
+ if cmd in ("printd", "print_devices", "print_all_devices"):
161
+ call_admin("print_all_devices")
162
+ return
163
+
164
+ # ----- rm -----
165
+ if cmd == "rm":
166
+ if len(tokens) < 3:
167
+ print("Usage: admin rm <aa|ar|a> [username]")
168
+ return
169
+
170
+ sub = tokens[2].lower()
171
+
172
+ if sub == "aa":
173
+ call_admin("remove_all_users")
174
+ return
175
+
176
+ if sub == "ar":
177
+ call_admin("remove_all_reservations")
178
+ return
179
+
180
+ if sub == "a":
181
+ if len(tokens) < 4:
182
+ print("Usage: admin rm a <username>")
183
+ return
184
+ call_admin("remove_user", {"username": tokens[3]})
185
+ return
186
+
187
+ print("Unknown rm subcommand. Use: aa, ar, a <username>")
188
+ return
189
+
190
+ # ----- setacc -----
191
+ if cmd in ("setacc", "set_account", "setperm", "set"):
192
+ if len(tokens) < 4:
193
+ print("Usage: admin setacc <username> <U|P|A> [devices=1,2] [max_res=3] [max_time=1800]")
194
+ return
195
+
196
+ target_user = tokens[2]
197
+ perm = tokens[3].upper()
198
+
199
+ extra: dict = {"username": target_user, "permission": perm}
200
+
201
+ # Parse optional k=v args (very lightweight parser)
202
+ # Examples:
203
+ # devices=1,2,3
204
+ # max_res=5
205
+ # max_time=1800
206
+ for t in tokens[4:]:
207
+ if "=" not in t:
208
+ continue
209
+ k, v = t.split("=", 1)
210
+ k = k.strip().lower()
211
+ v = v.strip()
212
+
213
+ if k in ("devices", "device_list", "devices_allowed", "device_ids"):
214
+ # server-side remote_admin_call already supports "1,2,3" as string
215
+ extra["device_list"] = v
216
+ elif k in ("max_res", "max_reservations"):
217
+ extra["max_reservations"] = int(v)
218
+ elif k in ("max_time", "max_res_time", "max_reservation_time_sec"):
219
+ extra["max_reservation_time_sec"] = int(v)
220
+
221
+ call_admin("set_account", extra)
222
+ return
223
+
224
+ print(f"Unknown admin command: {cmd}. Try: admin help")
225
+
226
+
227
+ def remote_admin_rpc_client(
228
+ *,
229
+ function_name: str,
230
+ auth_un: str,
231
+ auth_pw: str,
232
+ args: Optional[Dict[str, Any]] = None,
233
+ raise_on_error: bool = False,
234
+ print_result: bool = False,
235
+ ) -> Dict[str, Any]:
236
+ """
237
+ Client helper for RemoteAdmin:<function> calls.
238
+
239
+ Builds and sends:
240
+ function_name = "RemoteAdmin:<function_name>"
241
+ args include:
242
+ auth_un, auth_pw (mapped via map_arg)
243
+ + any additional args (mapped via map_arg if not already grpc_pb2.Argument)
244
+
245
+ Returns:
246
+ {
247
+ "ok": bool,
248
+ "result": str | None,
249
+ "error": str | None,
250
+ "traceback": str | None,
251
+ "raw": grpc_pb2.GenericRPCResponse,
252
+ }
253
+ """
254
+ fn = (function_name or "").strip()
255
+ if fn.startswith("RemoteAdmin:"):
256
+ rpc_fn = fn
257
+ else:
258
+ rpc_fn = f"RemoteAdmin:{fn}"
259
+
260
+ payload: Dict[str, Any] = {
261
+ "auth_un": map_arg(auth_un),
262
+ "auth_pw": map_arg(auth_pw),
263
+ }
264
+
265
+ if args:
266
+ for k, v in args.items():
267
+ if v is None:
268
+ continue
269
+ # If caller already passed a grpc Argument, keep it.
270
+ if isinstance(v, grpc_pb2.Argument):
271
+ payload[str(k)] = v
272
+ else:
273
+ payload[str(k)] = map_arg(v)
274
+
275
+ resp = rpc_client(function_name=rpc_fn, args=payload)
276
+
277
+ # Parse the standardized RemoteAdmin response keys:
278
+ # Ok, Result, Error, Traceback (each typically map_arg-encoded)
279
+ results = getattr(resp, "results", {}) or {}
280
+
281
+ def _get_str(key: str) -> Optional[str]:
282
+ if key not in results:
283
+ return None
284
+ try:
285
+ return str(unmap_arg(results[key]))
286
+ except Exception:
287
+ try:
288
+ return str(results[key])
289
+ except Exception:
290
+ return None
291
+
292
+ ok_val = results.get("Ok", None)
293
+ ok = False
294
+ if ok_val is not None:
295
+ try:
296
+ ok = bool(unmap_arg(ok_val))
297
+ except Exception:
298
+ ok = False
299
+
300
+ out = {
301
+ "ok": ok,
302
+ "result": _get_str("Result"),
303
+ "error": _get_str("Error"),
304
+ "traceback": _get_str("Traceback"),
305
+ "raw": resp,
306
+ }
307
+
308
+ if print_result:
309
+ if out["ok"]:
310
+ print(out["result"] or "OK")
311
+ else:
312
+ print(out["error"] or "RemoteAdmin call failed.")
313
+ if out["traceback"]:
314
+ print(out["traceback"])
315
+
316
+ if raise_on_error and not out["ok"]:
317
+ msg = out["error"] or "RemoteAdmin call failed."
318
+ raise RuntimeError(msg)
319
+
320
+ return out
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: remoterf
3
- Version: 0.0.7.46
3
+ Version: 0.0.7.47
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: Ethan Ge
6
6
  Author-email: ethoGalaxy@gmail.com
@@ -14,6 +14,7 @@ Requires-Dist: protobuf<6.0.0,>=5.0.0
14
14
  Requires-Dist: numpy
15
15
  Requires-Dist: prompt_toolkit
16
16
  Requires-Dist: python-dotenv
17
+ Requires-Dist: prompt-toolkit
17
18
  Dynamic: author
18
19
  Dynamic: author-email
19
20
  Dynamic: classifier
@@ -18,19 +18,15 @@ src/remoteRF/common/utils/ansi_codes.py
18
18
  src/remoteRF/common/utils/api_token.py
19
19
  src/remoteRF/common/utils/list_string.py
20
20
  src/remoteRF/common/utils/process_arg.py
21
+ src/remoteRF/config/__init__.py
22
+ src/remoteRF/config/cert_fetcher.py
23
+ src/remoteRF/config/config_cli.py
21
24
  src/remoteRF/core/__init__.py
22
25
  src/remoteRF/core/acc_login.py
23
26
  src/remoteRF/core/app.py
24
27
  src/remoteRF/core/grpc_acc.py
25
28
  src/remoteRF/core/grpc_client.py
26
29
  src/remoteRF/core/version.py
27
- src/remoteRF/core/certs/__init__.py
28
- src/remoteRF/core/certs/ca.crt
29
- src/remoteRF/core/certs/ca.key
30
- src/remoteRF/core/certs/cert.pem
31
- src/remoteRF/core/certs/key.pem
32
- src/remoteRF/core/certs/server.crt
33
- src/remoteRF/core/certs/server.key
34
30
  src/remoteRF/drivers/__init__.py
35
31
  src/remoteRF/drivers/adalm_pluto/__init__.py
36
32
  src/remoteRF/drivers/adalm_pluto/pluto_remote.py
@@ -1,3 +1,4 @@
1
1
  [console_scripts]
2
+ remoterf-config = remoteRF.config.config_cli:main
2
3
  remoterf-login = remoteRF.core.acc_login:main
3
4
  remoterf-v = remoteRF.core.version:main
@@ -3,3 +3,4 @@ protobuf<6.0.0,>=5.0.0
3
3
  numpy
4
4
  prompt_toolkit
5
5
  python-dotenv
6
+ prompt-toolkit
@@ -1,32 +0,0 @@
1
- -----BEGIN CERTIFICATE-----
2
- MIIFmzCCA4OgAwIBAgIURcP62Zj3L/2bVIIdFu+UcAMklBQwDQYJKoZIhvcNAQEL
3
- BQAwXTELMAkGA1UEBhMCVVMxDjAMBgNVBAgMBVN0YXRlMQ0wCwYDVQQHDARDaXR5
4
- MRUwEwYDVQQKDAxDb21wYW55IE5hbWUxGDAWBgNVBAMMD3d3dy5leGFtcGxlLmNv
5
- bTAeFw0yNDA2M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mz1ZwM/mWRQBY8COk1ZdIf5vwXrPI+PyZ6
20
- HoiNQ3CLXJYn2TMatjmvi+I8tQ4w6e57EIa0VmxhDxoKgJky5v5C9jUcTufMriGC
21
- rGepbJMODXlV2Kn6omRwd/1Mb/j4oxB57PrZP6ldOKegKayckVJ5vTInAoGAUeP7
22
- l0XF65gzbSdlfFqhjWH/PiDNR+zSHclOeT45L2C4pj3f4Uz4uRiuxMI8CMs0JKNA
23
- fvugLAJosVbAVtB0mbesYnPo68hHsKAQoK4x0BiDuBH011RAymiZTzsigqB8eEnE
24
- j0A8aE61z0Bk/6jJCv9ntXYTx/MU9YEc+1jGYCECgYB9Y32sH3xV2LdMKlhFtjux
25
- WAyyAN+C7Ly8jzwpHQMxpSxHZ16tO/V+0mMIqZHRz1X+DKqO4h6t1j3Bn0u9Tm/i
26
- vXNDEfy9RF/9U16s0ByK6QzwTodevNg7SEP6YzagR6DlCzIwj0Xbs9m9BHT7Ypia
27
- J2qGfS7rsnmSP31AtQhikA==
28
- -----END PRIVATE KEY-----
@@ -1,100 +0,0 @@
1
- import socket
2
- import getpass
3
- from pathlib import Path
4
-
5
- import grpc
6
- from ..common.grpc import grpc_pb2
7
- from ..common.grpc import grpc_pb2_grpc
8
- from ..common.utils import *
9
-
10
- # wlab credentials
11
- server_ip = '164.67.195.207'
12
- server_port = '61005'
13
-
14
- options = [
15
- ('grpc.max_send_message_length', 100 * 1024 * 1024),
16
- ('grpc.max_receive_message_length', 100 * 1024 * 1024),
17
- ]
18
-
19
- # Server.crt
20
- certs_path = Path(__file__).resolve().parent.parent/'core'/'certs'/'server.crt'
21
- with certs_path.open('rb') as f:
22
- trusted_certs = f.read()
23
-
24
- credentials = grpc.ssl_channel_credentials(root_certificates=trusted_certs)
25
- channel = grpc.secure_channel(f'{server_ip}:{server_port}', credentials, options=options)
26
- stub = grpc_pb2_grpc.GenericRPCStub(channel)
27
-
28
- tcp_calls = 0
29
-
30
- def get_tcp_calls():
31
- return tcp_calls
32
-
33
- def rpc_client(*, function_name, args):
34
- global tcp_calls
35
- tcp_calls += 1
36
- # print(tcp_calls)
37
- # if not is_connected:
38
- # response = rpc_client(function_name="UserLogin", args={"username": grpc_pb2.Argument(string_value=input("Username: ")), "password": grpc_pb2.Argument(string_value=getpass.getpass("Password: ")), "client_ip": grpc_pb2.Argument(string_value=local_ip)})
39
- # if (response.results['status'].string_value == 'Success'):
40
- # print("Login successful.")
41
- # is_connected = True
42
-
43
- # TODO: Handle user login
44
-
45
- # print(f"Opening connection to {server_ip}:{server_port}")
46
-
47
- # TODO: Handle Errors
48
-
49
- # print(f"Calling function: {function_name}")
50
- response = stub.Call(grpc_pb2.GenericRPCRequest(function_name=function_name, args=args))
51
-
52
- if 'a' in response.results:
53
- print(f"Error: {unmap_arg(response.results['a'])}")
54
- exit()
55
-
56
- if 'UE' in response.results:
57
- print(f"UserError: {unmap_arg(response.results['UE'])}")
58
- input("Hit enter to continue...")
59
-
60
- if 'Message' in response.results:
61
- print(f"{unmap_arg(response.results['Message'])}")
62
-
63
-
64
- return response
65
-
66
- #region Example Usage
67
-
68
- # if __name__ == '__main__':
69
- # args={
70
- # "key1": grpc_pb2.Argument(string_value="Hello"),
71
- # "key2": grpc_pb2.Argument(int32_value=123),
72
- # "key3": grpc_pb2.Argument(float_value=4.56),
73
- # "key4": grpc_pb2.Argument(bool_value=True),
74
- # "client_ip": grpc_pb2.Argument(string_value=local_ip)
75
- # }
76
-
77
- # response = rpc_client(function_name="echo", args=args)
78
-
79
- # if 'client_ip' in response.results:
80
- # del response.results['client_ip']
81
-
82
- # # Print results
83
- # print("Received response:")
84
- # for key, arg in response.results.items():
85
- # # Decode the oneof fields
86
- # if arg.HasField('string_value'):
87
- # value = arg.string_value
88
- # elif arg.HasField('int32_value'):
89
- # value = arg.int32_value
90
- # elif arg.HasField('float_value'):
91
- # value = arg.float_value
92
- # elif arg.HasField('bool_value'):
93
- # value = arg.bool_value
94
- # else:
95
- # value = "Undefined"
96
-
97
- # print(f"{key}: {value}")
98
-
99
- #endregion
100
-
File without changes
File without changes
File without changes
File without changes