github.com/letsencrypt/boulder@v0.20251208.0/va/config/config.go (about)

     1  package vacfg
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/letsencrypt/boulder/cmd"
     7  	"github.com/letsencrypt/boulder/config"
     8  )
     9  
    10  // Common contains all of the shared fields for a VA and a Remote VA (RVA).
    11  type Common struct {
    12  	cmd.ServiceConfig
    13  	// UserAgent is the "User-Agent" header sent during http-01 challenges and
    14  	// DoH queries.
    15  	UserAgent string
    16  
    17  	IssuerDomain string
    18  
    19  	// DNSTries is the number of times to try a DNS query (that has a temporary error)
    20  	// before giving up. May be short-circuited by deadlines. A zero value
    21  	// will be turned into 1.
    22  	DNSTries    int
    23  	DNSProvider *cmd.DNSProvider `validate:"required_without=DNSStaticResolvers"`
    24  	// DNSStaticResolvers is a list of DNS resolvers. Each entry must
    25  	// be a host or IP and port separated by a colon. IPv6 addresses
    26  	// must be enclosed in square brackets.
    27  	DNSStaticResolvers        []string        `validate:"required_without=DNSProvider,dive,hostname_port"`
    28  	DNSTimeout                config.Duration `validate:"required"`
    29  	DNSAllowLoopbackAddresses bool
    30  
    31  	// AccountURIPrefixes is a list of prefixes used to construct account URIs.
    32  	// The first prefix in the list is used for dns-account-01 challenges.
    33  	// All of the prefixes are used for CAA accounturi validation.
    34  	AccountURIPrefixes []string `validate:"min=1,dive,required,url"`
    35  }
    36  
    37  // SetDefaultsAndValidate performs some basic sanity checks on fields stored in
    38  // the Common struct, defaulting them to a sane value when necessary. This
    39  // method does mutate the Common struct.
    40  func (c *Common) SetDefaultsAndValidate(grpcAddr, debugAddr *string) error {
    41  	if *grpcAddr != "" {
    42  		c.GRPC.Address = *grpcAddr
    43  	}
    44  	if *debugAddr != "" {
    45  		c.DebugAddr = *debugAddr
    46  	}
    47  
    48  	if c.DNSTimeout.Duration <= 0 {
    49  		return fmt.Errorf("'dnsTimeout' is required")
    50  	}
    51  
    52  	if c.DNSTries < 1 {
    53  		c.DNSTries = 1
    54  	}
    55  
    56  	return nil
    57  }