mirror of
https://github.com/go-acme/lego.git
synced 2024-12-22 16:53:17 +02:00
chore: minor changes (#2108)
This commit is contained in:
parent
b9b0412f7c
commit
7fe1796157
@ -7,8 +7,6 @@ linters-settings:
|
||||
check-shadowing: true
|
||||
gocyclo:
|
||||
min-complexity: 12
|
||||
maligned:
|
||||
suggest-new: true
|
||||
goconst:
|
||||
min-len: 3
|
||||
min-occurrences: 3
|
||||
|
@ -39,14 +39,14 @@ func TestGenerateCSR(t *testing.T) {
|
||||
expected expected
|
||||
}{
|
||||
{
|
||||
desc: "without SAN",
|
||||
desc: "without SAN (nil)",
|
||||
privateKey: privateKey,
|
||||
domain: "lego.acme",
|
||||
mustStaple: true,
|
||||
expected: expected{len: 245},
|
||||
},
|
||||
{
|
||||
desc: "without SAN",
|
||||
desc: "without SAN (empty)",
|
||||
privateKey: privateKey,
|
||||
domain: "lego.acme",
|
||||
san: []string{},
|
||||
|
@ -12,6 +12,7 @@ const (
|
||||
// limited on the "new-reg", "new-authz" and "new-cert" endpoints.
|
||||
// From the documentation the limitation is 20 requests per second,
|
||||
// but using 20 as value doesn't work but 18 do.
|
||||
// https://letsencrypt.org/docs/rate-limits/
|
||||
overallRequestLimit = 18
|
||||
)
|
||||
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"fmt"
|
||||
"net"
|
||||
"os"
|
||||
"slices"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -216,12 +217,10 @@ func fetchSoaByFqdn(fqdn string, nameservers []string) (*soaCacheEntry, error) {
|
||||
|
||||
// dnsMsgContainsCNAME checks for a CNAME answer in msg.
|
||||
func dnsMsgContainsCNAME(msg *dns.Msg) bool {
|
||||
for _, ans := range msg.Answer {
|
||||
if _, ok := ans.(*dns.CNAME); ok {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.ContainsFunc(msg.Answer, func(rr dns.RR) bool {
|
||||
_, ok := rr.(*dns.CNAME)
|
||||
return ok
|
||||
})
|
||||
}
|
||||
|
||||
func dnsQuery(fqdn string, rtype uint16, nameservers []string, recursive bool) (*dns.Msg, error) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
.PHONY: default clean hugo hugo-build
|
||||
|
||||
default: hugo
|
||||
default: clean hugo
|
||||
|
||||
clean:
|
||||
rm -rf public/
|
||||
|
@ -3,6 +3,7 @@ package tester
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"slices"
|
||||
)
|
||||
|
||||
// EnvTest Environment variables manager for tests.
|
||||
@ -143,10 +144,5 @@ func (e *EnvTest) Apply(envVars map[string]string) {
|
||||
}
|
||||
|
||||
func (e *EnvTest) isManagedKey(varName string) bool {
|
||||
for _, key := range e.keys {
|
||||
if key == varName {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
return slices.Contains(e.keys, varName)
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ func (c *Client) GetDomainInformation(ctx context.Context, fqdn string) (*Data,
|
||||
|
||||
authZone, err := dns01.FindZoneByFqdn(fqdn)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("cloudflare: could not find zone for FQDN %q: %w", fqdn, err)
|
||||
return nil, fmt.Errorf("could not find zone for FQDN %q: %w", fqdn, err)
|
||||
}
|
||||
|
||||
var domains []Data
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"slices"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
@ -272,13 +273,11 @@ func containsValue(record *internal.Record, value string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
for _, val := range record.Value {
|
||||
if val.Value == fmt.Sprintf(`%q`, value) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
qValue := fmt.Sprintf(`%q`, value)
|
||||
|
||||
return false
|
||||
return slices.ContainsFunc(record.Value, func(val internal.RecordValue) bool {
|
||||
return val.Value == qValue
|
||||
})
|
||||
}
|
||||
|
||||
func backoff(min, max time.Duration, attemptNum int, resp *http.Response) time.Duration {
|
||||
|
@ -4,6 +4,7 @@ package edgedns
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -224,13 +225,9 @@ func getZone(domain string) (string, error) {
|
||||
}
|
||||
|
||||
func containsValue(values []string, value string) bool {
|
||||
for _, val := range values {
|
||||
if strings.Trim(val, `"`) == value {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
return slices.ContainsFunc(values, func(val string) bool {
|
||||
return strings.Trim(val, `"`) == value
|
||||
})
|
||||
}
|
||||
|
||||
func isNotFound(err error) bool {
|
||||
|
@ -28,7 +28,7 @@ func (p *configProvider) PrivateRSAKey() (*rsa.PrivateKey, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return common.PrivateKeyFromBytes(privateKey, common.String(p.privateKeyPassphrase))
|
||||
return common.PrivateKeyFromBytesWithPassword(privateKey, []byte(p.privateKeyPassphrase))
|
||||
}
|
||||
|
||||
func (p *configProvider) KeyID() (string, error) {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"slices"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@ -309,10 +310,8 @@ func decodeCredentials(accountB64 string) (ycsdk.Credentials, error) {
|
||||
}
|
||||
|
||||
func appendRecordSetData(record *ycdns.RecordSet, value string) bool {
|
||||
for _, data := range record.GetData() {
|
||||
if data == value {
|
||||
return false
|
||||
}
|
||||
if slices.Contains(record.GetData(), value) {
|
||||
return false
|
||||
}
|
||||
|
||||
record.SetData(append(record.GetData(), value))
|
||||
|
Loading…
Reference in New Issue
Block a user