golang / go

The Go programming language
https://go.dev
BSD 3-Clause "New" or "Revised" License
123k stars 17.53k forks source link

net: LookupSRV and search domains when name is empty #9391

Open nikhilofthesouth opened 9 years ago

nikhilofthesouth commented 9 years ago

Using Go 1.4 on Linux x86_64 (Ubuntu).

I called the lookupSRV function in the "net" package, with lookupSRV("service", "tcp", "") (empty name).

I expected this to lookup using my search domains ("_service._tcp.my.search.domain"), but it potentially seems to have queried it with an extra "." ("_service._tcp..my.search.domain").

Is this intended? Or am I just using the function in a strange way? The workaround I'm using right now is to call lookupSRV("", "", "_service._tcp") instead.

ianlancetaylor commented 9 years ago

You are using the function in a strange way but I can't think of a good reason why it shouldn't work. @mikioh

minux commented 9 years ago

We just need to add a special case for name=="" to src/net/lookup_*.go

zachgersh commented 9 years ago

Have a change in review for this :smile: https://go-review.googlesource.com/#/c/3569/

mikioh commented 9 years ago

RFC 2782 clearly states that "Clients ask for a specific service/protocol for a specific domain (the word domain is used here in the strict RFC 1034 sense), and get back the names of any available servers." In mDNS, we use a new label "local." and in DNS-SD something more complicated. But those are requirements for protocols, not for built-in stub resolver implementation, API surfaces.

I wonder If we extend LookupSRV to be able to accept an empty string as a local domain or a wild card, what about other lookup APIs such as LookMX, LookupHost? Moreover, what if we extend both LookupSRV and LookupTXT to DNS-SD?

At this moment I have no concrete opinion on this issue, but fixing this issue with #8540 seems reasonable.

zachgersh commented 9 years ago

Hey @mikioh - thanks so much for the feedback (I also saw your comment on Gerrit). I wouldn't mind making these updates and solving #8540.

Would love to discuss some more details about the change you are suggesting (implementing DNS-SD) - maybe we move to an implementation discussion over on that issue?

gopherbot commented 9 years ago

CL https://golang.org/cl/3569 mentions this issue.