From 4f2f91a2238add979a3dac1a8cea9ecd409ca5bc Mon Sep 17 00:00:00 2001 From: Matthew McPherrin Date: Fri, 24 May 2024 16:28:40 -0400 Subject: [PATCH] Fix linter complaints --- challtestsrv/dns.go | 2 +- challtestsrv/dnsone.go | 2 +- challtestsrv/event.go | 5 +---- challtestsrv/httpone.go | 2 +- challtestsrv/tlsalpnone.go | 6 +++--- va/va.go | 2 +- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/challtestsrv/dns.go b/challtestsrv/dns.go index ee0c3bc9..a01d2c38 100644 --- a/challtestsrv/dns.go +++ b/challtestsrv/dns.go @@ -158,7 +158,7 @@ func (s *ChallSrv) caaAnswers(q dns.Question) []dns.RR { } type writeMsg interface { - WriteMsg(*dns.Msg) error + WriteMsg(msg *dns.Msg) error } type dnsToHTTPWriter struct { diff --git a/challtestsrv/dnsone.go b/challtestsrv/dnsone.go index 228e86f2..5dd61b33 100644 --- a/challtestsrv/dnsone.go +++ b/challtestsrv/dnsone.go @@ -72,7 +72,7 @@ func (s *doh) ListenAndServe() error { } // dohServer creates a DoH server. -func dohServer(address string, tlsCert, tlsCertKey string, handler http.Handler) (challengeServer, error) { +func dohServer(address string, tlsCert, tlsCertKey string, handler http.Handler) (*doh, error) { return &doh{ &http.Server{ Handler: handler, diff --git a/challtestsrv/event.go b/challtestsrv/event.go index ea7713b6..171fd81e 100644 --- a/challtestsrv/event.go +++ b/challtestsrv/event.go @@ -70,10 +70,7 @@ func (e DNSRequestEvent) Type() RequestEventType { // in the question name is removed. func (e DNSRequestEvent) Key() string { key := e.Question.Name - if strings.HasSuffix(key, ".") { - key = strings.TrimSuffix(key, ".") - } - return key + return strings.TrimSuffix(key, ".") } // TLSALPNRequestEvent corresponds to a TLS request received by diff --git a/challtestsrv/httpone.go b/challtestsrv/httpone.go index 7e90c639..69cec000 100644 --- a/challtestsrv/httpone.go +++ b/challtestsrv/httpone.go @@ -181,7 +181,7 @@ func (c challHTTPServer) Shutdown() error { // resulting challengeServer will run a HTTPS server with a self-signed // certificate useful for HTTP-01 -> HTTPS HTTP-01 redirect responses. If HTTPS // is false the resulting challengeServer will run an HTTP server. -func httpOneServer(address string, handler http.Handler, https bool) challengeServer { +func httpOneServer(address string, handler http.Handler, https bool) challHTTPServer { // If HTTPS is requested build a TLS Config that uses the self-signed // certificate generated at startup. var tlsConfig *tls.Config diff --git a/challtestsrv/tlsalpnone.go b/challtestsrv/tlsalpnone.go index 22b1fc3a..5e8c845b 100644 --- a/challtestsrv/tlsalpnone.go +++ b/challtestsrv/tlsalpnone.go @@ -69,7 +69,7 @@ func (s *ChallSrv) ServeChallengeCertFunc(k *ecdsa.PrivateKey) func(*tls.ClientH kaHash := sha256.Sum256([]byte(ka)) extValue, err := asn1.Marshal(kaHash[:]) if err != nil { - return nil, fmt.Errorf("failed marshalling hash OCTET STRING: %s", err) + return nil, fmt.Errorf("failed marshaling hash OCTET STRING: %w", err) } certTmpl := x509.Certificate{ SerialNumber: big.NewInt(1729), @@ -84,7 +84,7 @@ func (s *ChallSrv) ServeChallengeCertFunc(k *ecdsa.PrivateKey) func(*tls.ClientH } certBytes, err := x509.CreateCertificate(rand.Reader, &certTmpl, &certTmpl, k.Public(), k) if err != nil { - return nil, fmt.Errorf("failed creating challenge certificate: %s", err) + return nil, fmt.Errorf("failed creating challenge certificate: %w", err) } return &tls.Certificate{ Certificate: [][]byte{certBytes}, @@ -107,7 +107,7 @@ func (c challTLSServer) ListenAndServe() error { return c.Server.ListenAndServeTLS("", "") } -func tlsALPNOneServer(address string, challSrv *ChallSrv) challengeServer { +func tlsALPNOneServer(address string, challSrv *ChallSrv) challTLSServer { key, err := ecdsa.GenerateKey(elliptic.P256(), rand.Reader) if err != nil { panic(err) diff --git a/va/va.go b/va/va.go index 4fc65c0e..d3f5349b 100644 --- a/va/va.go +++ b/va/va.go @@ -24,8 +24,8 @@ import ( "github.com/miekg/dns" - "github.com/letsencrypt/pebble/v2/challtestsrv" "github.com/letsencrypt/pebble/v2/acme" + "github.com/letsencrypt/pebble/v2/challtestsrv" "github.com/letsencrypt/pebble/v2/core" "github.com/letsencrypt/pebble/v2/db" )