aboutsummaryrefslogtreecommitdiff
path: root/middleware/httpproxy/tls.go
blob: 2c05a033113c9f36533d87fbee904a43dda4915e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package httpproxy

import (
	"crypto/tls"
	"net/http"
	"time"

	"github.com/miekg/coredns/request"
	"github.com/miekg/dns"
)

// Exchanger is an interface that specifies a type implementing a DNS resolver that
// uses a HTTPS server.
type Exchanger interface {
	Exchange(request.Request) (*dns.Msg, error)

	SetUpstream(*simpleUpstream) error
	OnStartup() error
	OnShutdown() error
}

func newClient(sni string) *http.Client {
	tls := &tls.Config{ServerName: sni}

	c := &http.Client{
		Timeout:   time.Second * timeOut,
		Transport: &http.Transport{TLSClientConfig: tls},
	}

	return c
}

const timeOut = 5