Skip to content
This repository was archived by the owner on Oct 23, 2026. It is now read-only.

Fix SNI: Add hostname field to ServiceInfo - #11

Merged
kaidokert merged 5 commits into
youtube:mainfrom
kaidokert:fix/sni
Jan 19, 2026
Merged

kaidokert merged 5 commits into
youtube:mainfrom
kaidokert:fix/sni

Conversation

@kaidokert

@kaidokert kaidokert commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor

Add hostname field to ServiceInfo struct to properly support TLS Server Name Indication (SNI). The hostname is used for network addressing and TLS SNI, representing the DNS/mDNS hostname that resolves to the device's IP address.

Changes:

  • Add hostname field to ServiceInfo struct with documentation
  • Rename service_info_from_mdns_resolved() to service_info_from_mdns()
  • Extract hostname from mDNS resolved service
  • Use hostname instead of IP address for QUIC connect()
  • Update mock publisher and tests to include hostname

Fixes #3

Add hostname field to ServiceInfo struct to properly support TLS Server
Name Indication (SNI). The hostname is used for network addressing and
TLS SNI, representing the DNS/mDNS hostname that resolves to the device's
IP address.

Changes:
- Add hostname field to ServiceInfo struct with documentation
- Rename service_info_from_mdns_resolved() to service_info_from_mdns()
- Extract hostname from mDNS resolved service
- Use hostname instead of IP address for QUIC connect()
- Update mock publisher and tests to include hostname
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello @kaidokert, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the ServiceInfo structure by introducing a hostname field, which is essential for correctly implementing TLS Server Name Indication (SNI) and improving network addressing. The change ensures that QUIC connections can properly negotiate TLS using the service's hostname, rather than just its IP address. This involves updating mDNS service resolution logic to extract the hostname and modifying mock components and tests to accommodate the new field.

Highlights

  • ServiceInfo Structure Enhancement: The ServiceInfo struct now includes a new hostname field, crucial for proper TLS Server Name Indication (SNI) and network addressing. This field is populated with the DNS/mDNS hostname that resolves to the device's IP address.
  • mDNS Service Resolution Update: The utility function service_info_from_mdns_resolved has been renamed to service_info_from_mdns and updated to extract and assign the hostname from mDNS resolved service information.
  • QUIC Connection Logic Adjustment: QUIC connection initiation has been modified to utilize the newly introduced hostname field instead of the IP address string for TLS SNI, ensuring correct server certificate validation.
  • Mocking and Testing Updates: Mock implementations and test cases across openscreen-discovery-mock and openscreen-discovery have been updated to correctly handle and populate the new hostname field, maintaining consistency and test coverage.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request effectively adds support for TLS SNI by introducing a hostname field to ServiceInfo. The changes are well-implemented, especially the extraction of the hostname from mDNS records and the excellent documentation updates for the ServiceInfo struct. The use of the new hostname field in the QUIC client connection is also correct. I have one suggestion regarding the direct connection mode in the app-sender example to improve consistency with the new hostname field's documentation.

@kaidokert

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request correctly introduces a hostname field to ServiceInfo to support TLS SNI. The changes are well-implemented across the discovery and application layers, including updates to documentation, mocks, and tests. I have a couple of suggestions for improvement: one to make IP address resolution more robust in the sender application, and another to clarify documentation in ServiceInfo.

Replace IP address parsing with tokio::net::lookup_host to support both
hostnames and IP addresses for the --direct-host argument. This resolves
a semantic inconsistency where ServiceInfo.hostname was documented to
hold a "DNS/mDNS hostname" but was actually receiving an IP address string.

The implementation prefers IPv4 addresses when available, consistent with
the mDNS discovery behavior. This avoids potential connectivity issues on
networks with misconfigured IPv6 support.
@kaidokert

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adds the hostname field to ServiceInfo to support TLS Server Name Indication (SNI), which is a crucial fix. The changes are well-integrated across the different crates, including the application, mDNS discovery implementation, and mock testing utilities. My review includes a couple of suggestions for improvement: one to correctly parse the user-friendly display_name from the mDNS service name, and another to fix a minor inconsistency in a documentation example.

Comment thread openscreen-discovery-mdns/src/utils.rs Resolved
Implement display name extraction to remove the service suffix from the
full mDNS service name, making it more user-friendly for display.

The full mDNS service name has the format:
  <instance>._openscreen._udp.local.

For example:
  - Full: "Living Room TV._openscreen._udp.local."
  - Display: "Living Room TV"
@kaidokert

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request correctly adds support for TLS Server Name Indication (SNI) by introducing a hostname field to ServiceInfo and using it during the QUIC connection. The changes are well-structured, including updates to mDNS discovery logic, mocks, and tests. I've identified a potential bug in the display name extraction logic and a minor documentation inconsistency. Overall, this is a solid improvement for secure connections.

Comment thread openscreen-discovery-mdns/src/utils.rs Resolved
Implement display name extraction to remove the service suffix from the
full mDNS service name, making it more user-friendly for display.

The full mDNS service name has the format:
  <instance>.<service>

For example:
  - Full: "Living Room TV._openscreen._udp.local."
  - Display: "Living Room TV"
@kaidokert

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Code Review

This pull request correctly implements support for TLS Server Name Indication (SNI) by adding a hostname field to the ServiceInfo struct and using it during the QUIC connection process. The changes are consistently applied across all relevant crates, including application logic, mDNS discovery, and mock implementations. The documentation has been significantly improved, clarifying the different name and identifier fields. The addition of new tests for the display name extraction logic is also a welcome improvement. My review found one minor issue where an unwrap_or could be simplified to unwrap for better clarity and idiomatic code, but overall this is a high-quality contribution that addresses an important feature.

Comment thread openscreen-discovery-mdns/src/utils.rs Resolved
@kaidokert
kaidokert merged commit 70770cb into youtube:main Jan 19, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TLS SNI uses IP address instead of agent hostname

1 participant