Add server instance to the context in ServerTLS and ServerHTTPS (#2840)

* Add server instance to the context in ServerTLS and ServerHTTPS

The problem with the current code is that there's no way to get the server instance inside a plugin.
Because of that "metrics" plugin sets empty "server" label for requests served over TLS or HTTPS.

* use s.Server instead of s

* Added server to the context of grpc requests
This commit is contained in:
Andrey Meshkov
2019-05-27 17:52:48 +03:00
committed by Miek Gieben
parent c5f49257be
commit aebbc4883d
3 changed files with 5 additions and 3 deletions

View File

@@ -117,7 +117,8 @@ func (s *ServerHTTPS) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// We just call the normal chain handler - all error handling is done there.
// We should expect a packet to be returned that we can send to the client.
s.ServeDNS(context.Background(), dw, msg)
ctx := context.WithValue(context.Background(), Key{}, s.Server)
s.ServeDNS(ctx, dw, msg)
// See section 4.2.1 of RFC 8484.
// We are using code 500 to indicate an unexpected situation when the chain