ratelimits: Rename DomainsForRateLimiting() to clarify use (#7746)
Rename as suggested by @jsha in #7729.
This commit is contained in:
parent
56d392793a
commit
d656afce78
2
ra/ra.go
2
ra/ra.go
|
@ -1547,7 +1547,7 @@ func (ra *RegistrationAuthorityImpl) checkCertificatesPerNameLimit(ctx context.C
|
|||
return nil
|
||||
}
|
||||
|
||||
tldNames := ratelimits.DomainsForRateLimiting(names)
|
||||
tldNames := ratelimits.FQDNsToETLDsPlusOne(names)
|
||||
namesOutOfLimit, earliest, err := ra.enforceNameCounts(ctx, tldNames, limit, regID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("checking certificates per name limit for %q: %s",
|
||||
|
|
|
@ -326,7 +326,7 @@ func (builder *TransactionBuilder) certificatesPerDomainCheckOnlyTransactions(re
|
|||
}
|
||||
|
||||
var txns []Transaction
|
||||
for _, name := range DomainsForRateLimiting(orderDomains) {
|
||||
for _, name := range FQDNsToETLDsPlusOne(orderDomains) {
|
||||
perDomainBucketKey, err := newDomainBucketKey(CertificatesPerDomain, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -392,7 +392,7 @@ func (builder *TransactionBuilder) CertificatesPerDomainSpendOnlyTransactions(re
|
|||
}
|
||||
|
||||
var txns []Transaction
|
||||
for _, name := range DomainsForRateLimiting(orderDomains) {
|
||||
for _, name := range FQDNsToETLDsPlusOne(orderDomains) {
|
||||
perDomainBucketKey, err := newDomainBucketKey(CertificatesPerDomain, name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -12,10 +12,10 @@ func joinWithColon(args ...string) string {
|
|||
return strings.Join(args, ":")
|
||||
}
|
||||
|
||||
// DomainsForRateLimiting transforms a list of FQDNs into a list of eTLD+1's
|
||||
// for the purpose of rate limiting. It also de-duplicates the output
|
||||
// domains. Exact public suffix matches are included.
|
||||
func DomainsForRateLimiting(names []string) []string {
|
||||
// FQDNsToETLDsPlusOne transforms a list of FQDNs into a list of eTLD+1's for
|
||||
// the CertificatesPerDomain limit. It also de-duplicates the output domains.
|
||||
// Exact public suffix matches are included.
|
||||
func FQDNsToETLDsPlusOne(names []string) []string {
|
||||
var domains []string
|
||||
for _, name := range names {
|
||||
domain, err := publicsuffix.Domain(name)
|
||||
|
|
|
@ -6,22 +6,22 @@ import (
|
|||
"github.com/letsencrypt/boulder/test"
|
||||
)
|
||||
|
||||
func TestDomainsForRateLimiting(t *testing.T) {
|
||||
domains := DomainsForRateLimiting([]string{})
|
||||
func TestFQDNsToETLDsPlusOne(t *testing.T) {
|
||||
domains := FQDNsToETLDsPlusOne([]string{})
|
||||
test.AssertEquals(t, len(domains), 0)
|
||||
|
||||
domains = DomainsForRateLimiting([]string{"www.example.com", "example.com"})
|
||||
domains = FQDNsToETLDsPlusOne([]string{"www.example.com", "example.com"})
|
||||
test.AssertDeepEquals(t, domains, []string{"example.com"})
|
||||
|
||||
domains = DomainsForRateLimiting([]string{"www.example.com", "example.com", "www.example.co.uk"})
|
||||
domains = FQDNsToETLDsPlusOne([]string{"www.example.com", "example.com", "www.example.co.uk"})
|
||||
test.AssertDeepEquals(t, domains, []string{"example.co.uk", "example.com"})
|
||||
|
||||
domains = DomainsForRateLimiting([]string{"www.example.com", "example.com", "www.example.co.uk", "co.uk"})
|
||||
domains = FQDNsToETLDsPlusOne([]string{"www.example.com", "example.com", "www.example.co.uk", "co.uk"})
|
||||
test.AssertDeepEquals(t, domains, []string{"co.uk", "example.co.uk", "example.com"})
|
||||
|
||||
domains = DomainsForRateLimiting([]string{"foo.bar.baz.www.example.com", "baz.example.com"})
|
||||
domains = FQDNsToETLDsPlusOne([]string{"foo.bar.baz.www.example.com", "baz.example.com"})
|
||||
test.AssertDeepEquals(t, domains, []string{"example.com"})
|
||||
|
||||
domains = DomainsForRateLimiting([]string{"github.io", "foo.github.io", "bar.github.io"})
|
||||
domains = FQDNsToETLDsPlusOne([]string{"github.io", "foo.github.io", "bar.github.io"})
|
||||
test.AssertDeepEquals(t, domains, []string{"bar.github.io", "foo.github.io", "github.io"})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue