grandcat / zeroconf

mDNS / DNS-SD Service Discovery in pure Go (also known as Bonjour)
Other
748 stars 172 forks source link

localhost only #106

Open pkpowell opened 2 years ago

pkpowell commented 2 years ago

Is it possible to only publish on localhost and not lan-wide, i.e. the equivalent of dns-sd -lo -P... ? Use case is to prevent vpn addresses used by some clients from leaking onto the lan.

dns-sd -lo                          (Run dns-sd cmd using local only interface)
pkpowell commented 2 years ago

The following works (assuming index: 1 is always the loopback interface).

interfaces = []net.Interface{
    net.Interface{
        Index: 1,
    },
}
zeroconf.RegisterProxy(*name, *service, *domain, *port, *host, []string{*ip}, []string{"txtv=0", "lo=1", "la=2"}, interfaces)