Implement authenticated public relay and Rust device daemons

This commit is contained in:
tongtong committed 2026-11-12 12:33:39 +08:00
1 parent f96c1aa109
commit e1c152a657
29 files changed
+3244 -39

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
# Replace with your actual DNS name. Caddy obtains a public certificate.
# Keep the relay HTTP listener on loopback. Do not enable URL access logs
# containing session / lease query tickets without redaction.
devices.example.com {
reverse_proxy 127.0.0.1:8080
}
+9
View File
@@ -0,0 +1,9 @@
# Process management examples
Examples are templates, not installed automatically. Replace paths, domain, user and tokens before use. Public endpoints require HTTPS/WSS.
- Linux: create a dedicated `ads` user and `/opt/ads`; protect `/etc/ads/*.env` so only the intended account/root can read them. `server.env` contains `ADS_AGENT_TOKEN=...` and `ADS_CLIENT_TOKEN=...`; `agent.env` contains only `ADS_AGENT_TOKEN=...`. Copy the respective systemd unit to `/etc/systemd/system/`, then enable it. The local client normally runs as the desktop user, so it shares that user's ADB server and keys.
- macOS: edit the launchd plist, restrict its file permissions, and install it as the appropriate user's LaunchAgent. It contains a credential, so do not publish the edited file. Client launchd configuration can use the same pattern with `ads-client` and `ADS_CLIENT_TOKEN`.
- Windows: the binaries run as foreground long-lived processes. Use Task Scheduler to launch them under the intended account at logon, with a startup wrapper that sets the token environment variable, and configure restart on failure. Keep wrapper/config files readable only by that account and administrators. Native Service Control Manager support and installers are not implemented; do not use `sc.exe create` directly on these binaries.
These templates have not been exercised on Linux/macOS yet. Test the binaries and process manager on each target platform before relying on unattended startup.
+18
View File
@@ -0,0 +1,18 @@
[Unit]
Description=Android Device Streaming gateway
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=ads
WorkingDirectory=/opt/ads
EnvironmentFile=/etc/ads/agent.env
ExecStart=/opt/ads/ads-agent --server wss://devices.example.com --device home-phone --target 192.168.100.141:5555
Restart=on-failure
RestartSec=3
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
+18
View File
@@ -0,0 +1,18 @@
[Unit]
Description=Android Device Streaming relay
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=ads
WorkingDirectory=/opt/ads
EnvironmentFile=/etc/ads/server.env
ExecStart=/opt/ads/ads-server --listen 127.0.0.1:8080
Restart=on-failure
RestartSec=3
NoNewPrivileges=true
PrivateTmp=true
[Install]
WantedBy=multi-user.target
+17
View File
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0"><dict>
<key>Label</key><string>com.example.ads-agent</string>
<key>ProgramArguments</key><array>
<string>/opt/ads/ads-agent</string>
<string>--server</string><string>wss://devices.example.com</string>
<string>--device</string><string>home-phone</string>
<string>--target</string><string>192.168.100.141:5555</string>
</array>
<key>EnvironmentVariables</key><dict>
<key>ADS_AGENT_TOKEN</key><string>REPLACE_WITH_YOUR_RANDOM_AGENT_TOKEN</string>
</dict>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
<key>ThrottleInterval</key><integer>5</integer>
</dict></plist>