validate object implements the corresponding interface (#3724)
Signed-off-by: zouyee <zounengren@cmss.chinamobile.com>
This commit is contained in:
parent
b8e96b61fc
commit
a74a209129
5 changed files with 20 additions and 0 deletions
|
@ -52,6 +52,9 @@ func (h *dnsContext) saveConfig(key string, cfg *Config) {
|
||||||
h.keysToConfigs[key] = cfg
|
h.keysToConfigs[key] = cfg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile-time check to ensure dnsContext implements the caddy.Context interface
|
||||||
|
var _ caddy.Context = &dnsContext{}
|
||||||
|
|
||||||
// InspectServerBlocks make sure that everything checks out before
|
// InspectServerBlocks make sure that everything checks out before
|
||||||
// executing directives and otherwise prepares the directives to
|
// executing directives and otherwise prepares the directives to
|
||||||
// be parsed and executed.
|
// be parsed and executed.
|
||||||
|
|
|
@ -20,6 +20,7 @@ import (
|
||||||
"github.com/coredns/coredns/plugin/pkg/transport"
|
"github.com/coredns/coredns/plugin/pkg/transport"
|
||||||
"github.com/coredns/coredns/request"
|
"github.com/coredns/coredns/request"
|
||||||
|
|
||||||
|
"github.com/caddyserver/caddy"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
ot "github.com/opentracing/opentracing-go"
|
ot "github.com/opentracing/opentracing-go"
|
||||||
)
|
)
|
||||||
|
@ -99,6 +100,9 @@ func NewServer(addr string, group []*Config) (*Server, error) {
|
||||||
return s, nil
|
return s, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile-time check to ensure Server implements the caddy.GracefulServer interface
|
||||||
|
var _ caddy.GracefulServer = &Server{}
|
||||||
|
|
||||||
// Serve starts the server with an existing listener. It blocks until the server stops.
|
// Serve starts the server with an existing listener. It blocks until the server stops.
|
||||||
// This implements caddy.TCPServer interface.
|
// This implements caddy.TCPServer interface.
|
||||||
func (s *Server) Serve(l net.Listener) error {
|
func (s *Server) Serve(l net.Listener) error {
|
||||||
|
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/coredns/coredns/plugin/pkg/reuseport"
|
"github.com/coredns/coredns/plugin/pkg/reuseport"
|
||||||
"github.com/coredns/coredns/plugin/pkg/transport"
|
"github.com/coredns/coredns/plugin/pkg/transport"
|
||||||
|
|
||||||
|
"github.com/caddyserver/caddy"
|
||||||
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
|
"github.com/grpc-ecosystem/grpc-opentracing/go/otgrpc"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
"github.com/opentracing/opentracing-go"
|
"github.com/opentracing/opentracing-go"
|
||||||
|
@ -43,6 +44,9 @@ func NewServergRPC(addr string, group []*Config) (*ServergRPC, error) {
|
||||||
return &ServergRPC{Server: s, tlsConfig: tlsConfig}, nil
|
return &ServergRPC{Server: s, tlsConfig: tlsConfig}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile-time check to ensure Server implements the caddy.GracefulServer interface
|
||||||
|
var _ caddy.GracefulServer = &Server{}
|
||||||
|
|
||||||
// Serve implements caddy.TCPServer interface.
|
// Serve implements caddy.TCPServer interface.
|
||||||
func (s *ServergRPC) Serve(l net.Listener) error {
|
func (s *ServergRPC) Serve(l net.Listener) error {
|
||||||
s.m.Lock()
|
s.m.Lock()
|
||||||
|
|
|
@ -14,6 +14,8 @@ import (
|
||||||
"github.com/coredns/coredns/plugin/pkg/response"
|
"github.com/coredns/coredns/plugin/pkg/response"
|
||||||
"github.com/coredns/coredns/plugin/pkg/reuseport"
|
"github.com/coredns/coredns/plugin/pkg/reuseport"
|
||||||
"github.com/coredns/coredns/plugin/pkg/transport"
|
"github.com/coredns/coredns/plugin/pkg/transport"
|
||||||
|
|
||||||
|
"github.com/caddyserver/caddy"
|
||||||
)
|
)
|
||||||
|
|
||||||
// ServerHTTPS represents an instance of a DNS-over-HTTPS server.
|
// ServerHTTPS represents an instance of a DNS-over-HTTPS server.
|
||||||
|
@ -44,6 +46,9 @@ func NewServerHTTPS(addr string, group []*Config) (*ServerHTTPS, error) {
|
||||||
return sh, nil
|
return sh, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile-time check to ensure Server implements the caddy.GracefulServer interface
|
||||||
|
var _ caddy.GracefulServer = &Server{}
|
||||||
|
|
||||||
// Serve implements caddy.TCPServer interface.
|
// Serve implements caddy.TCPServer interface.
|
||||||
func (s *ServerHTTPS) Serve(l net.Listener) error {
|
func (s *ServerHTTPS) Serve(l net.Listener) error {
|
||||||
s.m.Lock()
|
s.m.Lock()
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/coredns/coredns/plugin/pkg/reuseport"
|
"github.com/coredns/coredns/plugin/pkg/reuseport"
|
||||||
"github.com/coredns/coredns/plugin/pkg/transport"
|
"github.com/coredns/coredns/plugin/pkg/transport"
|
||||||
|
|
||||||
|
"github.com/caddyserver/caddy"
|
||||||
"github.com/miekg/dns"
|
"github.com/miekg/dns"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -35,6 +36,9 @@ func NewServerTLS(addr string, group []*Config) (*ServerTLS, error) {
|
||||||
return &ServerTLS{Server: s, tlsConfig: tlsConfig}, nil
|
return &ServerTLS{Server: s, tlsConfig: tlsConfig}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Compile-time check to ensure Server implements the caddy.GracefulServer interface
|
||||||
|
var _ caddy.GracefulServer = &Server{}
|
||||||
|
|
||||||
// Serve implements caddy.TCPServer interface.
|
// Serve implements caddy.TCPServer interface.
|
||||||
func (s *ServerTLS) Serve(l net.Listener) error {
|
func (s *ServerTLS) Serve(l net.Listener) error {
|
||||||
s.m.Lock()
|
s.m.Lock()
|
||||||
|
|
Loading…
Add table
Reference in a new issue