-
Notifications
You must be signed in to change notification settings - Fork 267
Add time synchronization feature for devices without cellular connectivity #718
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR implements a time synchronization feature for devices without cellular connectivity by introducing a time offset approach that corrects timestamps without modifying the system clock. The implementation stores an in-memory offset that is applied to all rayhunter-generated timestamps (manifest entries and PCAP files). Additionally, the PR includes a devenv.nix development environment configuration for reproducible builds.
Key Changes
- Time correction module that calculates and stores offset between browser time and system time
- API endpoints for retrieving current offset and syncing time from browser
- Frontend TimeSyncCard component with user-friendly offset display and one-click sync
- PCAP and manifest timestamps are corrected on-the-fly when served via API
- Development environment setup using devenv for reproducible builds
Reviewed changes
Copilot reviewed 12 out of 14 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| daemon/src/time_correction.rs | Core time correction module with offset calculation and storage |
| daemon/src/stats.rs | Applies time corrections to manifest entry timestamps |
| daemon/src/pcap.rs | Applies time corrections to PCAP file generation |
| daemon/src/server.rs | API endpoints for time correction (GET and POST) |
| daemon/src/main.rs | Integrates time correction state and routes |
| lib/src/pcap.rs | Adds method to write PCAP messages with corrected datetime |
| daemon/web/src/lib/components/TimeSyncCard.svelte | UI component for time synchronization |
| daemon/web/src/lib/utils.svelte.ts | Client-side API functions for time correction |
| daemon/web/src/routes/+page.svelte | Integrates TimeSyncCard into main page |
| devenv.nix | Development environment configuration with Rust and Node.js setup |
| devenv.yaml | DevEnv inputs configuration for rust-overlay |
| devenv.lock | Lock file for devenv dependencies |
| .envrc | Direnv configuration for automatic environment loading |
| Cargo.lock | Version bump to 0.8.0 for installer-gui |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review for a chance to win a $100 gift card. Take the survey.
|
@i-am-logger gave it a quick look, code looks okay. here's three requests:
|
|
@untitaker, I removed the devenv commit and fixed copilot comments, sorry didn't realize it will auto-trigger. The pcap.rs changes apply time correction to downloaded PCAP/ZIP files so they match the corrected timestamps shown in the UI. QMDL files stay raw since changing timestamps there would break checksums. Happy to remove the PCAP changes if you prefer, though it's an open question whether users need corrected timestamps in downloaded files. |
e8bb135 to
4ee47c5
Compare
Summary
This PR implements a time delta/offset approach to fix incorrect timestamps on devices that cannot sync via NITZ (e.g., devices without active SIM cards). Instead of modifying the system clock (which requires root and may fail), we store a time offset in memory and apply it to all rayhunter-generated timestamps.
Addresses #121
Implementation Details
Backend
daemon/src/time_correction.rs: TimeCorrection module that stores offset in seconds and provides sync/get methodsGET /api/time-correction- Get current offset and last sync timePOST /api/time-correction/sync- Sync time from browser timestampapply_time_correction()instats.rswrite_gsmtap_message_with_datetime()inpcap.rsFrontend
How it works
/api/time-correction/syncbrowser_time - system_timeBenefits
date -sfailsTesting
Note on QMDL Files
QMDL files remain unmodified as they are raw binary diagnostic logs that should preserve data integrity. Only generated/served content (manifest entries, PCAP files) have corrected timestamps.
Open Question for Maintainers
Should we store the offset per-recording in the manifest to enable proper timestamp correlation between QMDL and PCAP files?
Currently, all recordings use the current global offset, which means:
Potential solutions:
offset_secondsin eachManifestEntry(preserves the offset used at recording time)Would appreciate guidance on which approach aligns better with the project goals.
Additional Commit
This PR also includes a devenv.nix setup commit for a reproducible development environment (similar to the PDS project structure). This is separate from the feature and can be reviewed independently or split into a separate PR if preferred.
🤖 Generated with Claude Code