@@ -66,8 +66,8 @@ func reader(ctx context.Context, conn *net.UDPConn) chan *dnsMsg {
6666 }
6767 slog .Debug ("received UDP message" , "bytes" , bytesRead , "from" , remoteAddress )
6868
69- if err := dnsMsg .msg .Unpack (buf [:bytesRead ]); err != nil {
70- dnsMsg .err = errors .Join (dnsMsg .err , fmt .Errorf ("failed to unpack message: %w" , err ))
69+ if unpackErr := dnsMsg .msg .Unpack (buf [:bytesRead ]); unpackErr != nil {
70+ dnsMsg .err = errors .Join (dnsMsg .err , fmt .Errorf ("failed to unpack message: %w" , unpackErr ))
7171 msgCh <- dnsMsg
7272 continue
7373 }
@@ -81,10 +81,11 @@ func reader(ctx context.Context, conn *net.UDPConn) chan *dnsMsg {
8181}
8282
8383// selectQuestion filters and selects questions with the given FQDN suffix.
84- func selectQuestion (fqdn string , qs []dns.Question ) ( res []string ) {
84+ func selectQuestion (fqdn string , qs []dns.Question ) []string {
8585 suffix := strings .ToLower ("." + fqdn )
8686 slog .Debug ("filtering DNS questions" , "suffix" , suffix , "questions" , len (qs ))
8787
88+ res := make ([]string , 0 , len (qs ))
8889 for _ , q := range qs {
8990 slog .Debug ("processing question" , "name" , q .Name , "type" , dns .TypeToString [q .Qtype ])
9091
@@ -114,8 +115,8 @@ func runSubdomain(ctx context.Context, publisher *avahi.Publisher, fqdn string,
114115 <- ctx .Done ()
115116 fmt .Println () // Add new line after ^C
116117 slog .Info ("closing connection" )
117- if err := conn .Close (); err != nil {
118- slog .Error ("failed to close connection" , "error" , err )
118+ if closeErr := conn .Close (); closeErr != nil {
119+ slog .Error ("failed to close connection" , "error" , closeErr )
119120 }
120121 }()
121122
@@ -132,8 +133,8 @@ func runSubdomain(ctx context.Context, publisher *avahi.Publisher, fqdn string,
132133
133134 if len (found ) > 0 {
134135 slog .Debug ("publishing matching CNAMEs" , "count" , len (found ))
135- if err := publisher .PublishCNAMES (found , ttl ); err != nil {
136- return fmt .Errorf ("failed to publish CNAMEs: %w" , err )
136+ if publishErr := publisher .PublishCNAMES (found , ttl ); publishErr != nil {
137+ return fmt .Errorf ("failed to publish CNAMEs: %w" , publishErr )
137138 }
138139 }
139140 }
0 commit comments