feat(resolvers/HTTPS): add HTTP proxy support #119

Merged
sam merged 2 commits from http-proxy-support into master 2022-09-28 18:08:56 +00:00
Owner

Turns out this was really easy and probably a nice-to-have

Turns out this was really easy and probably a nice-to-have
sam added 1 commit 2022-09-27 21:03:58 +00:00
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
f22ca2f82f
feat(resolvers/HTTPS): add HTTP proxy support
grumbulon reviewed 2022-09-27 23:11:36 +00:00
@ -26,6 +27,17 @@ func (resolver *HTTPSResolver) LookUp(msg *dns.Msg) (util.Response, error) {
httpR := &http.Client{
Collaborator

This is small and meant to be more of a talking point than a hard and fast thing that needs to be done.

I was thinking since HTTPSResolver is declared here do we need to declare a new struct we can keep everything inside of the HTTPSResolver object like so

// HTTPSResolver is for DNS-over-HTTPS queries.
type HTTPSResolver struct {
	client http.Client
	opts   util.Options
}

var _ Resolver = (*HTTPSResolver)(nil)

// LookUp performs a DNS query.
func (resolver *HTTPSResolver) LookUp(msg *dns.Msg) (util.Response, error) {
	var resp util.Response

	resolver.client = http.Client{
		Timeout: resolver.opts.Request.Timeout,
		Transport: &http.Transport{
			MaxConnsPerHost:     1,
			MaxIdleConns:        1,
			MaxIdleConnsPerHost: 1,
			Proxy:               http.ProxyFromEnvironment,
			TLSClientConfig: &tls.Config{
				//nolint:gosec // This is intentional if the user requests it
				InsecureSkipVerify: resolver.opts.TLSNoVerify,
				ServerName:         resolver.opts.TLSHost,
			},
		},
	}

and on line 59 we can keep it all under the resolver as res, err := resolver.client.Do(req)

Besides that lgtm, just curious what you think about this.

This is small and meant to be more of a talking point than a hard and fast thing that needs to be done. I was thinking since HTTPSResolver is declared here do we need to declare a new struct we can keep everything inside of the HTTPSResolver object like so ```Go // HTTPSResolver is for DNS-over-HTTPS queries. type HTTPSResolver struct { client http.Client opts util.Options } var _ Resolver = (*HTTPSResolver)(nil) // LookUp performs a DNS query. func (resolver *HTTPSResolver) LookUp(msg *dns.Msg) (util.Response, error) { var resp util.Response resolver.client = http.Client{ Timeout: resolver.opts.Request.Timeout, Transport: &http.Transport{ MaxConnsPerHost: 1, MaxIdleConns: 1, MaxIdleConnsPerHost: 1, Proxy: http.ProxyFromEnvironment, TLSClientConfig: &tls.Config{ //nolint:gosec // This is intentional if the user requests it InsecureSkipVerify: resolver.opts.TLSNoVerify, ServerName: resolver.opts.TLSHost, }, }, } ``` and on [line 59](https://git.froth.zone/sam/awl/src/commit/f22ca2f82f5d49a6f1ba80b7814dc9cca71ce0a1/pkg/resolvers/HTTPS.go#L59) we can keep it all under the resolver as ` res, err := resolver.client.Do(req)` Besides that lgtm, just curious what you think about this.
sam added 1 commit 2022-09-28 14:55:01 +00:00
continuous-integration/drone/push Build is passing Details
continuous-integration/drone/pr Build is passing Details
937d0826e3
fix: apply suggested change
I like it so I'm keeping it :)
grumbulon approved these changes 2022-09-28 17:46:51 +00:00
sam merged commit f01f2bc15a into master 2022-09-28 18:08:56 +00:00
sam deleted branch http-proxy-support 2022-09-28 18:08:56 +00:00
Sign in to join this conversation.
No description provided.