Skip to content
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

fix(mdns): don't hardcode mDNS instance name #3084

Merged
merged 2 commits into from
Aug 25, 2024

Conversation

cgutman
Copy link
Collaborator

@cgutman cgutman commented Aug 25, 2024

Description

All platform mDNS implemenations currently hardcode the instance name to Sunshine. This causes reliable name collisions during mDNS registration when more than one Sunshine host is running on the same network. The collision is eventually resolved by appending a number to the name, but this is unnecessary work and delay for nothing. We should just register using our hostname as the instance name most other mDNS services do.

Screenshot

Issues Fixed or Closed

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Dependency update (updates to dependencies)
  • Documentation update (changes to documentation)
  • Repository update (changes to repository files, e.g. .github/...)

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have added or updated the in code docstring/documentation-blocks for new or existing methods/components

src/network.cpp Outdated
*/
std::string
mdns_instance_name() {
std::string hostname = boost::asio::ip::host_name();
Copy link
Member

@ReenigneArcher ReenigneArcher Aug 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this became an argument for the function, the unit testing could be parametrized with various hostnames to check if it will work for all the scenarios provided.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in the latest commit.

Copy link

codecov bot commented Aug 25, 2024

Codecov Report

Attention: Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 9.54%. Comparing base (f048510) to head (a7b43d3).
Report is 116 commits behind head on master.

Files with missing lines Patch % Lines
src/platform/windows/publish.cpp 0.00% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##           master   #3084      +/-   ##
=========================================
- Coverage    9.66%   9.54%   -0.13%     
=========================================
  Files         101      77      -24     
  Lines       17942   14040    -3902     
  Branches     8381    6442    -1939     
=========================================
- Hits         1734    1340     -394     
+ Misses      13328   10082    -3246     
+ Partials     2880    2618     -262     
Flag Coverage Δ
Linux ?
Windows 5.08% <78.57%> (+0.08%) ⬆️
macOS-12 10.46% <63.63%> (+0.04%) ⬆️
macOS-13 10.37% <63.63%> (+0.04%) ⬆️
macOS-14 10.68% <63.63%> (+0.06%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/network.cpp 24.56% <100.00%> (+8.87%) ⬆️
src/network.h 0.00% <ø> (ø)
src/platform/macos/publish.cpp 5.12% <ø> (-2.57%) ⬇️
src/platform/windows/publish.cpp 0.00% <0.00%> (ø)

... and 54 files with indirect coverage changes

---- 🚨 Try these New Features:

@@ -105,7 +105,8 @@ namespace platf::publish {
&serviceRef,
0, // flags
0, // interfaceIndex
SERVICE_NAME, SERVICE_TYPE,
nullptr, // name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you're giving it a nullptr, it won't use net::mdns_instance_name() for macOS at all, and the tests aren't useful for macOS right?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, the function is unused on macOS.

Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants