@@ -3,7 +3,9 @@ package mdns
33import (
44 "context"
55 "encoding/base64"
6+ "net"
67 "os"
8+ "strings"
79
810 "github.com/functionland/go-fula/wap/pkg/config"
911 wifi "github.com/functionland/go-fula/wap/pkg/wifi"
@@ -145,6 +147,35 @@ func StartServer(ctx context.Context, port int) *MDNSServer {
145147 return server
146148}
147149
150+ // getLANInterfaces returns network interfaces excluding Docker/virtual bridges.
151+ // Returns nil (all interfaces) as fallback if no physical interfaces found.
152+ func getLANInterfaces () []net.Interface {
153+ ifaces , err := net .Interfaces ()
154+ if err != nil {
155+ return nil
156+ }
157+
158+ var filtered []net.Interface
159+ for _ , iface := range ifaces {
160+ // Skip down or loopback interfaces
161+ if iface .Flags & net .FlagUp == 0 || iface .Flags & net .FlagLoopback != 0 {
162+ continue
163+ }
164+ // Skip Docker bridges and virtual ethernet pairs
165+ if iface .Name == "docker0" ||
166+ strings .HasPrefix (iface .Name , "br-" ) ||
167+ strings .HasPrefix (iface .Name , "veth" ) {
168+ continue
169+ }
170+ filtered = append (filtered , iface )
171+ }
172+
173+ if len (filtered ) == 0 {
174+ return nil // fallback: let library use all interfaces
175+ }
176+ return filtered
177+ }
178+
148179func NewZeroConfService (port int ) (* MDNSServer , error ) {
149180 meta := createInfo ()
150181 log .Debugw ("mdns meta created" , "meta" , meta )
@@ -155,7 +186,7 @@ func NewZeroConfService(port int) (*MDNSServer, error) {
155186 "local." , // service domain
156187 port , // service port
157188 meta , // service metadata
158- nil , // register on all network interfaces
189+ getLANInterfaces (), // only physical/LAN interfaces
159190 )
160191
161192 if err != nil {
0 commit comments