push-kwqqssknoszv #2

Merged
eric merged 10 commits from push-kwqqssknoszv into main 2026-11-12 20:42:48 +01:00
Owner
No description provided.
eric added 10 commits 2026-11-12 20:42:25 +01:00
Refactor the `Catalog` to use maps for instances and service records, improving how keys are handled. Move test logic from `live.rs` to `lib.rs` and add new tests for error handling and label validation.

- Update `Catalog` in `src/catalog.rs` to use `BTreeMap` for instances and services, making `emitted` public and updating `absorb`, `missing`, and `changed` methods accordingly.
- Modify `src/unicast.rs`'s `ask` function to check for packet existence before sending, logging debug messages if no packet is found.
- Enhance `src/wire.rs` by adding `Srv` and `A` variants to `Rdata`, updating `query` to return `Option<Vec<u8>>`, and enforcing label constraints in `read_name`.
- Add new tests in `src/tests/catalog.rs` for service name case matching and refused services, and in `src/tests/wire.rs` for label validation and TXT record handling.
- Create `src/tests/error.rs` with tests for `PmomdnsError` variants, ensuring proper error conversion and message exposure.
- Add `src/tests/lib.rs` containing `every_caller_gets_the_same_daemon` (moved from `live.rs`) and `concurrent_callers_all_get_a_working_daemon`.
- Update `src/tests/mod.rs` to replace `mod live` with `mod error`, `mod lib`, and `mod unicast`.
- Refactor `tests/api.rs` to use `daemon_or_skip` and `skip_without_network` helpers for better network constraint handling.
- Add documentation comments and forbid unsafe code in `src/lib.rs`.
Add proptest for property-based testing and update flume features. Refine
test cases in catalog and wire modules to cover edge cases like truncated
records and invalid pointers. Simplify API tests by removing network
dependencies and unused helper functions.

- Add `proptest` dev-dependency and enable `async` feature on `flume`.
- Update `Cargo.lock` with new dependencies including `autocfg`, `borsh`,
  `rand`, and `serde`.
- Add catalog tests: `a_change_of_port_or_of_text_is_resolved_again`,
  `an_srv_of_an_unannounced_instance_is_never_resolved`,
  `several_instances_are_resolved_independently`.
- Add wire tests: `full_response`, `a_pointer_outside_the_packet_is_refused`,
  `a_truncated_record_keeps_the_ones_read_before_it`,
  `a_packet_without_the_response_bit_is_not_read`,
  `authority_and_additional_records_are_read`,
  `an_aaaa_record_is_skipped_and_the_next_one_is_still_read`,
  `an_empty_name_is_read_as_the_root`,
  `a_packet_cut_inside_the_fixed_fields_gives_nothing`.
- Remove `daemon_or_skip` and `skip_without_network` from `tests/api.rs`.
- Update `browse_rejects_an_invalid_service_type` to remove `None` check.
- Update `browse_returns_a_live_receiver` to assert `ServiceEvent::SearchStarted(_)`.
- Update `daemon_can_be_called_repeatedly` to call `daemon()` twice.
Refactor the unicast module to filter interfaces for usable IPv4 addresses and allow configurable multicast groups. Update test infrastructure in `unicast.rs` to use the new `spawn` API and add helper functions for testing.

- Add `usable_v4` function to `src/unicast.rs` to filter out loopback and link-local IPv4 addresses.
- Modify `open_sockets`, `ask`, `run`, and `spawn` in `src/unicast.rs` to accept a `group` parameter instead of hardcoding `MDNS_GROUP`.
- Update `run` to use the provided `open` function for socket iteration and update `ask` signature.
- Add `Responder` struct and helper functions (`encode`, `record`, `answer`, etc.) to `src/tests/unicast.rs`.
- Modify `live_unicast_search_finds_devices` test in `src/tests/unicast.rs` to use `crate::unicast::spawn`.
Refactor the unicast module to manage network interfaces via explicit links rather than raw sockets. This introduces a `Link` structure to track IP and response state, replacing the previous `open_sockets` approach with `bind_interface` and `sync_links`.

- Move `open_sockets` logic into new `bind_interface`, `list_interfaces`, and `during` helpers in src/unicast.rs
- Update `run` to use `Link` structs for tracking responses and request complements based on `COMPLEMENT_RETRY`
- Modify test `start` signature to accept mutable closure returning `Vec<Vec<u8>> + Send + 'static`
- Add tests for service resolution time limits, skipped interfaces, and single socket opening across rounds
Refactor the unicast module to use `mio` for socket management, replacing `UdpSocket` with `MioSocket`. Update dependency configuration in `Cargo.toml` and `Cargo.lock` to include `mio` version 1. Refine the `usable_v4` function to filter interfaces based on operational status and point-to-point attributes.

- Add `mio` dependency (v1) with "os-poll" and "net" features to `Cargo.toml` and update `Cargo.lock`.
- Update `usable_v4` signature in `src/unicast.rs` to accept `IfOperStatus` and `point_to_point` bool for stricter filtering.
- Replace `UdpSocket` with `MioSocket` in `bind_interface` and `ask` signatures within `src/unicast.rs`.
- Add `ask_complements` and `drain` functions to handle service complement requests and response draining.
- Modify `run` logic to use `Poll::new()` for error handling and incorporate complement request checking during polling.
- Update `sync_links` to deregister sockets before binding and handle registration with a `Token`.
- Remove `only_routable_ipv4_interfaces_are_used` test from `src/tests/unicast.rs`.
- Add `idle_wakeups_stay_rare` test to verify interface wakeup limits over time.
- Add `only_routable_ipv4_interfaces_in_service_are_used` test for IPv4 address behavior.
- Update `search` and `an_interface_that_cannot_be_opened_is_skipped_and_the_others_still_work` tests to remove `set_read_timeout`.
Update lib.rs to document that the daemon performs unicast IPv4 searches only, noting that IPv6-only devices are not found. Add a `no_run` test block using `ServiceEvent` from `pmomdns::mdns_sd`.
Refine the `PmomdnsError` enum to replace generic errors with specific variants (`DaemonCreation`, `InvalidServiceType`, `DaemonBusy`, `DaemonStopped`, `Subscription`) and update `Thread` to use a `SearchKind` enum. This change improves error granularity by mapping `mdns_sd::Error` instances to precise variants via `from_subscription` and updating the `browse` and `daemon` functions to use these new types.

- Update `src/error.rs`: Add `SearchKind` enum with `Multicast`/`Unicast` variants and `Display` implementation; modify `PmomdnsError` to include new specific variants; add `from_subscription` helper for mapping `mdns_sd::Error`.
- Update `src/lib.rs`: Modify `daemon` to return `PmomdnsError::DaemonCreation`; update `browse` to map errors via `from_subscription`; update thread spawning logic to use `SearchKind` for multicast and unicast searches.
- Update `tests/api.rs`: Adjust `browse_rejects_an_invalid_service_type` to assert on `PmomdnsError::InvalidServiceType` and specific error message prefix.
- Update `src/tests/error.rs`: Add tests for new error variants (`DaemonCreation`, `InvalidServiceType`, `DaemonBusy`, `DaemonStopped`, `Subscription`) and `SearchKind`; remove obsolete tests for old generic error handling.
- Update `README.md`: Document new `PmomdnsError` variants and updated return types for `browse`.
Refactor the `ServiceDaemon` to be lazily initialized and persistent, moving its logic into a new `src/daemon.rs` module. Introduce a shared subscription mechanism where multiple subscribers of the same service type share a single multicast subscription, preventing redundant network traffic.

- Move `daemon` function and related static management from `src/lib.rs` to `src/daemon.rs`, introducing `Daemon` struct with `register`, `unregister`, and `shared` helpers.
- Replace `browse()` return type with `Subscription`, which shares events among subscribers of the same service type and handles cleanup on drop.
- Introduce internal modules `registry`, `merge`, and `subscription` to handle event merging, topic tracking, and subscription lifecycle management.
- Update `PmomdnsError` variants to include `SubscriptionRefused` and `AnnouncementRefused`, replacing `SearchKind` with `ThreadKind` for error categorization.
- Update tests in `src/tests/daemon.rs` (moved from `lib.rs`) and add new tests for merge logic, registry behavior, and subscription sharing in `tests/subscriptions.rs`.
- Bump package version to 0.2.0 and add "select" feature to `flume` dependency.
Refactor `subscribe` to use a new `subscribe_with` helper that encapsulates topic subscription setup. Add tests for unicast search lifecycle and failure scenarios using a shared atomic counter.

- Modify `src/registry.rs`: Extract `subscribe_with` from `subscribe` to handle browsing, spawning unicast threads, and merging; update docs to reflect unicast launch behavior.
- Modify `src/tests/registry.rs`: Add `Counted` struct with `UNICASTS` atomic counter for tracking lifecycle; add `reach` helper and tests `the_unicast_search_ends_once_the_last_subscriber_left` and `a_failure_to_start_the_unicast_search_leaves_nothing_behind`; update `mergers_reach` to use `reach`.
- Modify `src/unicast.rs`: Update `spawn` to increment the `UNICASTS` counter via `Counted::new` in test builds.
feat: add silent rounds config and refine service removal logic
All checks were successful
Release / release (push) Successful in 1m15s
4bfa1f2e0b
Introduce a configurable `silent_rounds` parameter to control unicast service
removal timeouts, adding new public API methods and error variants. Refine the
catalog and merge logic to properly handle cache flushes, PTR records with TTL 0,
and specific daemon/unicast interaction rules for service withdrawal.

- Add `src/settings.rs` with `DEFAULT_SILENT_ROUNDS`, `set_silent_rounds`, and
  `silent_rounds` to manage the unicast silence threshold.
- Update `src/lib.rs` and `README.md` to expose new daemon methods (`set_silent_rounds`,
  `silent_rounds`) and document the fixed unicast query intervals (1s, 2s, 20s).
- Modify `src/error.rs` to add `PmomdnsError::InvalidSilentRounds` for invalid config.
- Enhance `src/catalog.rs` with `forget`, `end_round`, and `departed` methods; update
  `absorb` to handle TTL 0 PTR records and cache flushes using new `answered`/`silence` maps.
- Refine `src/merge.rs` `admit` logic to prevent unicast silence from removing services
  explicitly described by the daemon.
- Update `src/unicast.rs` to make `interval` public, add `publish` for event dispatch, and
  adjust `run`/`drain` to use pacing and handle service removal events.
- Modify `src/wire.rs` to parse TTL and cache-flush flags from DNS responses into the `Record` struct.
- Add `api/0.2.0.json.gz`, `api/0.2.0.txt`, `api/0.2.1.json.gz`, and `api/0.2.1.txt` for
  public API documentation snapshots.
- Update version metadata in `.crate-kit/VERSION`, `Cargo.toml`, and `Cargo.lock`.
- Add tests in `src/tests/settings.rs` for silent rounds validation and update existing
  tests in `catalog.rs`, `merge.rs`, `unicast.rs`, and `wire.rs` to cover new logic.
eric merged commit 4cfd96d76f into main 2026-11-12 20:42:48 +01:00
eric deleted branch push-kwqqssknoszv 2026-11-12 20:42:50 +01:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
pmo/pmomdns!2
No description provided.