Repository navigation
feat(ServiceDaemon): possibility to use a specific network interface - #119
Marcondiro wants to merge 6 commits into
Conversation
Add the possibility of using a specific network interface using the on_interface constructor function. The addition is not a breaking change.
| /// | ||
| /// The daemon (re)uses the default mDNS port 5353. To keep it simple, we don't | ||
| /// ask callers to set the port. | ||
| pub fn on_interface(interface: &str) -> Result<Self> { |
There was a problem hiding this comment.
Can you specify or give examples about the interface string?
|
I still have to add the tests 🙂 |
keepsimple1
left a comment
There was a problem hiding this comment.
Thanks for your updates.
I also have a related thought: a different way to support interface filter is to add a new option in enum DaemonOption, instead of a new constructor. But because we create intf_socks in Zeroconf::new(), it seems a bit better to filter them during new(). So I think a new constructor is fine. Just sharing my thought anyway.
| [package] | ||
| name = "mdns-sd" | ||
| version = "0.7.4" | ||
| rust-version = "1.60.0" |
There was a problem hiding this comment.
And it's okay to bump up it a bit, just not too recent (for example 1.70 is too recent)
There was a problem hiding this comment.
Updated to 1.61, on 1.60 tests are failing because of a dependency.
| } | ||
|
|
||
| /// Creates a new daemon using a specific `interface` and spawns a thread to run the daemon. | ||
| /// |
There was a problem hiding this comment.
Can you add a bit more comment here to describe what it means to use a specific interface?
For example, something like: "the daemon will limit its service browsing and service publishing to this interface only". Feel free to word differently.
|
|
||
| /// Returns valid IPv4 interfaces in the host system. | ||
| fn my_ipv4_interfaces() -> Vec<Ifv4Addr> { | ||
| fn my_ipv4_interfaces(interface: Option<&str>) -> Vec<Ifv4Addr> { |
There was a problem hiding this comment.
With this change, I realized that the name my_ipv4_interfaces seems not very accurate because it returns only the address info. How about renaming it to my_ipv4_addrs ?
|
|
It was closed briefly by mistake, Sorry. I was trying to post a comment saying "I will review again after you add the test". |
|
One question: why do you bind the sockets to 0.0.0.0 ? Line 527 in ab24121 |
As I recall, if we bind the socket to a specific address, the |
Oh, ok thanks. I would prefer to generate traffic only on the interface specified |
Although we bind to INADDR_ANY (0.0.0.0), the multicast traffic only generates on the interface specified. Btw we don't support unicast at this point. If that's not the case for you, then we shall try to fix. |
|
Just wanted to let you know, I've posted a new release to fix issue #121 . So you would need to update your diff to resolve conflicts. And if you encountered any problems when adding the test, please let me know. |
Merged, thanks! |
keepsimple1
left a comment
There was a problem hiding this comment.
No problem, whenever you have time.
|
I have created a new PR that solves a problem and support this feature at the same time: #137 . Please take a look if you have time. Any comments are appreciated. Btw, with this change, you would do the following two steps to use a specific network interface: daemon.disable_interface(IfKind::All)?;
daemon.enable_interface(IfKind::Name("en0".to_string()))?;What do you think? The |
|
That's awesome, thank you! :) |
Add the possibility of using a specific network interface using the on_interface constructor function.
The addition is not a breaking change.
Hello, for my use case I need to use a specific network interface (that is also using a link local address) so I added this feature to your fantastic library.
If you think this could be useful (I do 😁) consider merging this PR or let me know if you want me to change something before merging.