feat: Add ruTorrent discovery via Zeroconf/mDNS (#75)
Closes #75
Summary
Adds a native mDNS/DNS-SD discovery feature to the login screen, allowing users to automatically find their ruTorrent servers on the local network without manual IP entry.
Changes
- [NEW] discovery_service.dart: Implements a lightweight mDNS scanner using raw UDP multicasting to avoid new external dependencies. It scans for the _rutorrent_mobile._tcp.local service type.
-
- login_view.dart: Added a 'Discover Servers' button that triggers the discovery process and displays results in a bottom sheet for easy selection and auto-filling of the URL.
-
- login_viewmodel.dart: Provides the UI with reactive state from the discovery service.
-
- app.dart & app.locator.dart: Registered the new DiscoveryService for dependency injection. This feature expects the ruTorrent server to be configured to advertise itself (e.g., via Avahi) using the _rutorrent_mobile._tcp service type.
Summary by CodeRabbit
- New Features
- Added local network server discovery functionality for ruTorrent services.
- Introduced "Discover Servers on Network" button on the login screen that displays a modal with available servers.
- Users can now automatically detect and select servers on their local network instead of manual entry.
This PR introduces local network discovery for ruTorrent servers using mDNS/DNS-SD protocol. A new π― 4 (Complex) | β±οΈ ~50 minutes π Through mDNS whispers the rabbit does quest,
Finding servers hidden in the network's nest,
With DNS parsing and multicast flair,
Discovery is answered in the network air! π βοΈ Tip: You can configure your own custom pre-merge checks in the settings.π Walkthrough
Walkthrough
DiscoveryService performs mDNS queries to find services on the network, and the login view integrates a discovery UI dialog allowing users to discover and select available servers.Changes
Cohort / File(s)
Summary
Dependency Registration
lib/app/app.dart, lib/app/app.locator.dartAdded
DiscoveryService as a lazy singleton to the service locator and dependency container.
Discovery Service Implementation
lib/services/functional_services/discovery_service.dartIntroduced
DiscoveredServer model and DiscoveryService class with mDNS-based discovery via UDP multicast, DNS response parsing (with name compression and SRV/TXT record extraction), timeout handling, and deduplication of discovered entries.
Login UI Integration
lib/ui/views/login/login_view.dartAdded "Discover Servers on Network" button and a modal bottom sheet dialog that displays discovery state and selectable server list via
ValueListenableBuilder.
Login ViewModel
lib/ui/views/login/login_viewmodel.dartExposed
discoveredServers and isDiscovering reactive getters and added discoverServers() async method to initiate discovery and handle empty-state feedback.Sequence Diagram
sequenceDiagram
participant User as User
participant LoginView as Login View
participant LoginVM as Login ViewModel
participant DiscoveryService as Discovery Service
participant Network as mDNS Network
User->>LoginView: Tap "Discover Servers on Network"
LoginView->>LoginVM: discoverServers()
activate LoginVM
LoginVM->>DiscoveryService: discover(timeout: 5s)
activate DiscoveryService
DiscoveryService->>Network: Bind UDP socket & join multicast group
DiscoveryService->>Network: Send mDNS PTR query
rect rgba(100, 150, 200, 0.5)
note over Network: Listen for UDP responses until timeout
Network-->>DiscoveryService: mDNS response packets
DiscoveryService->>DiscoveryService: Parse DNS response, extract SRV/TXT records
DiscoveryService->>DiscoveryService: Deduplicate by (host, port)
end
DiscoveryService-->>LoginVM: List<DiscoveredServer>
deactivate DiscoveryService
LoginVM->>LoginVM: Update discoveredServers ValueNotifier
LoginVM-->>LoginView: notifyListeners()
deactivate LoginVM
LoginView->>LoginView: Render discovered servers in modal
LoginView-->>User: Display list of available servers
User->>LoginView: Select a server
Estimated code review effort
Poem
π₯ Pre-merge checks | β
4 | β 1
β Failed checks (1 warning)
Check name
Status
Explanation
Resolution
Linked Issues check
β οΈ Warning
The PR implements mDNS discovery for ruTorrent servers and integrates it into the login interface. However, the PR lacks documentation for Avahi XML sample configuration and TXT record specifications required by issue
#75.Add documentation or sample files for Avahi XML configuration and document the TXT record format for protocol/URL metadata as outlined in issue
#75.β
Passed checks (4 passed)
Check name
Status
Explanation
Description Check
β
Passed
Check skipped - CodeRabbitβs high-level summary is enabled.
Title check
β
Passed
The title accurately describes the main change: adding ruTorrent discovery via Zeroconf/mDNS, which aligns with the primary objective of implementing service discovery.
Out of Scope Changes check
β
Passed
All changes are within scope: DiscoveryService implementation, dependency registration, UI integration, and ViewModel updates all directly support the mDNS discovery feature requested in issue
#75.
Docstring Coverage
β
Passed
No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
β¨ Finishing Touches
π§ͺ Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Comment @coderabbitai help to get the list of available commands and usage tips.