Merge pull request #11 from richtr/no_ipbind_warning_on_success
Add IP binding suppression if at least one UDP listener is registered
This commit is contained in:
commit
3e798410dc
17
server.go
17
server.go
@ -52,14 +52,8 @@ type Server struct {
|
||||
// NewServer is used to create a new mDNS server from a config
|
||||
func NewServer(config *Config) (*Server, error) {
|
||||
// Create the listeners
|
||||
ipv4List, err := net.ListenMulticastUDP("udp4", config.Iface, ipv4Addr)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
ipv4List, _ := net.ListenMulticastUDP("udp4", config.Iface, ipv4Addr)
|
||||
ipv6List, _ := net.ListenMulticastUDP("udp6", config.Iface, ipv6Addr)
|
||||
|
||||
// Check if we have any listener
|
||||
if ipv4List == nil && ipv6List == nil {
|
||||
@ -72,8 +66,15 @@ func NewServer(config *Config) (*Server, error) {
|
||||
ipv6List: ipv6List,
|
||||
shutdownCh: make(chan struct{}),
|
||||
}
|
||||
|
||||
if ipv4List != nil {
|
||||
go s.recv(s.ipv4List)
|
||||
}
|
||||
|
||||
if ipv6List != nil {
|
||||
go s.recv(s.ipv6List)
|
||||
}
|
||||
|
||||
return s, nil
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user