Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ func (c *Client) mainloop(ctx context.Context, params *lookupParams) {
}
if _, ok := entries[rr.Ptr]; !ok {
entries[rr.Ptr] = newServiceEntry(
trimDot(strings.Replace(rr.Ptr, rr.Hdr.Name, "", -1)),
trimDot(strings.ReplaceAll(rr.Ptr, rr.Hdr.Name, "")),
params.Service,
params.Domain)
}
Expand Down Expand Up @@ -368,7 +368,7 @@ func (c *Client) mainloop(ctx context.Context, params *lookupParams) {

// If this is an DNS-SD query do not throw PTR away.
// It is expected to have only PTR for enumeration
if params.ServiceRecord.ServiceTypeName() != params.ServiceRecord.ServiceName() {
if params.ServiceTypeName() != params.ServiceName() {
// Require at least one resolved IP address for ServiceEntry
// TODO: wait some more time as chances are high both will arrive.
if len(e.AddrIPv4) == 0 && len(e.AddrIPv6) == 0 {
Expand All @@ -391,10 +391,16 @@ func (c *Client) mainloop(ctx context.Context, params *lookupParams) {
// Shutdown client will close currently open connections and channel implicitly.
func (c *Client) shutdown() {
if c.ipv4conn != nil {
c.ipv4conn.Close()
err := c.ipv4conn.Close()
if err != nil {
log.Printf("[zeroconf] unable to cleanly close client IPv4 connection: %s", err.Error())
}
}
if c.ipv6conn != nil {
c.ipv6conn.Close()
err := c.ipv6conn.Close()
if err != nil {
log.Printf("[zeroconf] unable to cleanly close client IPv6 connection: %s", err.Error())
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions conn_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func (f *defaultConnectionFactory) CreateIPv4Conn(ifaces []net.Interface) (api.P
}
}
if failedJoins == len(ifaces) {
pkConn.Close()
_ = pkConn.Close()
return nil, fmt.Errorf("udp4: failed to join any of these interfaces: %v", ifaces)
}

Expand All @@ -62,7 +62,7 @@ func (f *defaultConnectionFactory) CreateIPv6Conn(ifaces []net.Interface) (api.P
}
}
if failedJoins == len(ifaces) {
pkConn.Close()
_ = pkConn.Close()
return nil, fmt.Errorf("udp6: failed to join any of these interfaces: %v", ifaces)
}

Expand Down
8 changes: 0 additions & 8 deletions interface_manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,6 @@ func mockInterface(index int, name string) net.Interface {
}
}

func mockInterfaces(specs ...struct{ idx int; name string }) []net.Interface {
result := make([]net.Interface, len(specs))
for i, s := range specs {
result[i] = mockInterface(s.idx, s.name)
}
return result
}

// ============================================================================
// NewInterfaceManager Tests
// ============================================================================
Expand Down
16 changes: 11 additions & 5 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,16 @@ func (s *Server) Shutdown() {
close(s.shouldShutdown)

if s.ipv4conn != nil {
s.ipv4conn.Close()
err := s.ipv4conn.Close()
if err != nil {
log.Printf("[zeroconf] unable to cleanly close server IPv4 connection: %s", err.Error())
}
}
if s.ipv6conn != nil {
s.ipv6conn.Close()
err := s.ipv6conn.Close()
if err != nil {
log.Printf("[zeroconf] unable to cleanly close server IPv6 connection: %s", err.Error())
}
}

// Wait for connection and routines to be closed
Expand Down Expand Up @@ -637,7 +643,7 @@ func (s *Server) probe() {
activeIfaces := mergeInterfaces(ipv4ActiveIfaces, ipv6ActiveIfaces)
for _, intf := range activeIfaces {
resp := new(dns.Msg)
resp.MsgHdr.Response = true
resp.Response = true
// TODO: make response authoritative if we are the publisher
resp.Compress = true
resp.Answer = []dns.RR{}
Expand All @@ -660,7 +666,7 @@ func (s *Server) probe() {
// announceText sends a Text announcement with cache flush enabled
func (s *Server) announceText() {
resp := new(dns.Msg)
resp.MsgHdr.Response = true
resp.Response = true

txt := &dns.TXT{
Hdr: dns.RR_Header{
Expand All @@ -678,7 +684,7 @@ func (s *Server) announceText() {

func (s *Server) unregister() error {
resp := new(dns.Msg)
resp.MsgHdr.Response = true
resp.Response = true
resp.Answer = []dns.RR{}
resp.Extra = []dns.RR{}
s.composeLookupAnswers(resp, 0, 0, true)
Expand Down
Loading