net: document LookupSRV cname return value
Document that the first return value of LookupSRV is the canonical
name of the DNS target that was looked up, which may differ from
the input name due to CNAME records.
Fixes #49982
diff --git a/src/net/lookup.go b/src/net/lookup.go
index d4be8ea..5ab4153 100644
--- a/src/net/lookup.go
+++ b/src/net/lookup.go
@@ -487,6 +487,9 @@
// publishing SRV records under non-standard names, if both service
// and proto are empty strings, LookupSRV looks up name directly.
//
+// The returned cname is the canonical name of the DNS target that was
+// looked up, which may differ from the input name due to CNAME records.
+//
// The returned service names are validated to be properly
// formatted presentation-format domain names. If the response contains
// invalid names, those records are filtered out and an error
@@ -505,6 +508,9 @@
// publishing SRV records under non-standard names, if both service
// and proto are empty strings, LookupSRV looks up name directly.
//
+// The returned cname is the canonical name of the DNS target that was
+// looked up, which may differ from the input name due to CNAME records.
+//
// The returned service names are validated to be properly
// formatted presentation-format domain names. If the response contains
// invalid names, those records are filtered out and an error
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Congratulations on opening your first change. Thank you for your contribution!
Next steps:
A maintainer will review your change and provide feedback. See
https://go.dev/doc/contribute#review for more info and tips to get your
patch through code review.
Most changes in the Go project go through a few rounds of revision. This can be
surprising to people new to the project. The careful, iterative review process
is our way of helping mentor contributors and ensuring that their contributions
have a lasting impact.
During May-July and Nov-Jan the Go project is in a code freeze, during which
little code gets reviewed or merged. If a reviewer responds with a comment like
R=go1.11 or adds a tag like "wait-release", it means that this CL will be
reviewed as part of the next development cycle. See https://go.dev/s/release
for more details.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Hold | +1 |
// looked up, which may differ from the input name due to CNAME records.I don't understand "...which may differ from the input name due to CNAME records". CNAME records don't seem to have anything to do with this name; so far as I can tell the first return parameter is entirely determined from the service, proto, and name parameters.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
net: document LookupSRV cname return value
Document that the first return value (cname) of LookupSRV and
Resolver.LookupSRV is the owner name from the first SRV answer
record, which is typically the constructed DNS name
(_service._proto.name) but may differ if CNAME records redirect
the query to another name.
Fixes #49982
diff --git a/src/net/lookup.go b/src/net/lookup.go
index d4be8ea..06e14df 100644
--- a/src/net/lookup.go
+++ b/src/net/lookup.go
@@ -487,6 +487,11 @@
// publishing SRV records under non-standard names, if both service
// and proto are empty strings, LookupSRV looks up name directly.
//
+// The returned cname is the owner name from the first SRV answer
+// record, which is typically the constructed DNS name
+// (_service._proto.name) but may differ if CNAME records redirect
+// the query to another name.
+//
// The returned service names are validated to be properly
// formatted presentation-format domain names. If the response contains
// invalid names, those records are filtered out and an error
@@ -505,6 +510,11 @@
// publishing SRV records under non-standard names, if both service
// and proto are empty strings, LookupSRV looks up name directly.
//
+// The returned cname is the owner name from the first SRV answer
+// record, which is typically the constructed DNS name
+// (_service._proto.name) but may differ if CNAME records redirect
+// the query to another name.
+//
// The returned service names are validated to be properly
// formatted presentation-format domain names. If the response contains
// invalid names, those records are filtered out and an error
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Yongqi Jia abandoned this change.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
// looked up, which may differ from the input name due to CNAME records.I don't understand "...which may differ from the input name due to CNAME records". CNAME records don't seem to have anything to do with this name; so far as I can tell the first return parameter is entirely determined from the service, proto, and name parameters.
Done.
You're right — the original wording was misleading. The cname return value isn't a CNAME record; it's the owner name from the first SRV answer record in the DNS response (see goLookupSRV in lookup.go around line 749, where cname = h.Name).
I've updated the documentation in PS2 to:
```
// The returned cname is the owner name from the first SRV answer
// record, which is typically the constructed DNS name
// (_service._proto.name) but may differ if CNAME records redirect
// the query to another name.
```
This makes clear that: (1) it comes from the DNS response header, not from CNAME records themselves; (2) it's typically identical to the constructed query name; (3) CNAME redirection is mentioned only as one possible reason for divergence, not as the definition.
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
| Code-Review | +1 |
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
Removed Hold+1 by Damien Neil <dn...@google.com>
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |
net: document LookupSRV cname return value
Document that the first return value of LookupSRV is the canonical
name of the DNS target that was looked up, which may differ from
the input name due to CNAME records.
Fixes #49982
| Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. |