Add IP binding suppression if at least one listener is registered
This commit is contained in:
parent
70462deb06
commit
095233e3dc
21
server.go
21
server.go
@ -52,14 +52,8 @@ type Server struct {
|
|||||||
// NewServer is used to create a new mDNS server from a config
|
// NewServer is used to create a new mDNS server from a config
|
||||||
func NewServer(config *Config) (*Server, error) {
|
func NewServer(config *Config) (*Server, error) {
|
||||||
// Create the listeners
|
// Create the listeners
|
||||||
ipv4List, err := net.ListenMulticastUDP("udp4", config.Iface, ipv4Addr)
|
ipv4List, _ := net.ListenMulticastUDP("udp4", config.Iface, ipv4Addr)
|
||||||
if err != nil {
|
ipv6List, _ := net.ListenMulticastUDP("udp6", config.Iface, ipv6Addr)
|
||||||
log.Printf("[ERR] mdns: Failed to start IPv4 listener: %v", err)
|
|
||||||
}
|
|
||||||
ipv6List, err := net.ListenMulticastUDP("udp6", config.Iface, ipv6Addr)
|
|
||||||
if err != nil {
|
|
||||||
log.Printf("[ERR] mdns: Failed to start IPv6 listener: %v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if we have any listener
|
// Check if we have any listener
|
||||||
if ipv4List == nil && ipv6List == nil {
|
if ipv4List == nil && ipv6List == nil {
|
||||||
@ -72,8 +66,15 @@ func NewServer(config *Config) (*Server, error) {
|
|||||||
ipv6List: ipv6List,
|
ipv6List: ipv6List,
|
||||||
shutdownCh: make(chan struct{}),
|
shutdownCh: make(chan struct{}),
|
||||||
}
|
}
|
||||||
go s.recv(s.ipv4List)
|
|
||||||
go s.recv(s.ipv6List)
|
if ipv4List != nil {
|
||||||
|
go s.recv(s.ipv4List)
|
||||||
|
}
|
||||||
|
|
||||||
|
if ipv6List != nil {
|
||||||
|
go s.recv(s.ipv6List)
|
||||||
|
}
|
||||||
|
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user