Skip to content

Commit

Permalink
Fix client multicast sending on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
davidflowerday committed Apr 13, 2022
1 parent a393c0e commit e52a29d
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,17 +443,21 @@ func (c *client) sendQuery(msg *dns.Msg) error {
return err
}
if c.ipv4conn != nil {
var wcm ipv4.ControlMessage
for ifi := range c.ifaces {
wcm.IfIndex = c.ifaces[ifi].Index
c.ipv4conn.WriteTo(buf, &wcm, ipv4Addr)
if err := c.ipv4conn.SetMulticastInterface(&c.ifaces[ifi]); err != nil {
// log.Printf("[WARN] mdns: Failed to set multicast interface: %v", err)
continue
}
c.ipv4conn.WriteTo(buf, nil, ipv4Addr)
}
}
if c.ipv6conn != nil {
var wcm ipv6.ControlMessage
for ifi := range c.ifaces {
wcm.IfIndex = c.ifaces[ifi].Index
c.ipv6conn.WriteTo(buf, &wcm, ipv6Addr)
if err := c.ipv6conn.SetMulticastInterface(&c.ifaces[ifi]); err != nil {
// log.Printf("[WARN] mdns: Failed to set multicast interface: %v", err)
continue
}
c.ipv6conn.WriteTo(buf, nil, ipv6Addr)
}
}
return nil
Expand Down

0 comments on commit e52a29d

Please sign in to comment.