Skip to content

refactoring: define our own interface struct to allow multiple addresses - #380

Merged
keepsimple1 merged 3 commits into
mainfrom
refactoring
Aug 7, 2025
Merged

keepsimple1 merged 3 commits into
mainfrom
refactoring

Conversation

@keepsimple1

@keepsimple1 keepsimple1 commented Aug 6, 2025 •

Copy link
Copy Markdown
Owner

This is triggered by #377 as currently we would skip 2nd IP address on an interface due to join_multicast_group error on the same interface. Strictly speaking, this is wrong and it can cause confusion in debugging as addr 1 is in ZeroConf.my_intfs but addr 2 (on the same interface) is not.

Also, currently we directly use Interface from if-addrs crate, but it is per address, not truly per interface. I took this opportunity to define a new interface struct for us MyIntf that represents a network interface that supports multiple addresses.

The diff is very extensive but conceptually really just Interface is replaced by MyIntf.

@keepsimple1

Copy link
Copy Markdown
Owner Author

@hrzlgnm I would like invite you to take a look at this, and possibly run some quick test with this PR if possible. It's OK to skip if no time.

@hrzlgnm

hrzlgnm commented Aug 6, 2025

Copy link
Copy Markdown
Contributor

@keepsimple1 Did some quick tests on Linux and Windows. LGTM.

Comment thread src/dns_parser.rs Outdated
HostIp::V6(v6) => {
if v6.scope_id.index != 0 {
write!(f, "{}%{}", v6.addr, v6.scope_id.index)
write!(f, "{}%{}", v6.addr, v6.scope_id.name)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please keep in mind, that the interface name is not usable on windows like this. As already discussed in:
#362 (comment)

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

I made the change during debugging and found it's helpful (on macOS and Linux), but forgot about it later. Thanks for the reminder. Now I updated it to use index on Windows and name on other platforms. Hope it's a meaningful trade-off?

@keepsimple1

Copy link
Copy Markdown
Owner Author

Thank you @hrzlgnm for reviewing!

@keepsimple1
keepsimple1 merged commit 52cc67c into main Aug 7, 2025
@keepsimple1
keepsimple1 deleted the refactoring branch August 7, 2025 03:49
keepsimple1 added a commit that referenced this pull request Nov 21, 2026
…t_bind (#555)

_new_socket_bind() has been unused by the daemon since #380 switched to shared IPv4/IPv6 sockets; only test_service_with_temporarily_invalidated_ptr still called it. The test now uses one new_multicast_socket() per IP family, and send_dns_outgoing_impl selects the outgoing interface for each send.
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.

2 participants