Set User-Agent header when fetching log list

This commit is contained in:
Andrew Ayer 2023-02-03 15:24:55 -05:00
parent 2366c06ca6
commit 2f2ad094db
2 changed files with 6 additions and 1 deletions

View File

@ -19,11 +19,13 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"runtime/debug"
"strings"
"syscall"
"time"
"software.sslmate.com/src/certspotter/loglist"
"software.sslmate.com/src/certspotter/monitor"
)
@ -103,7 +105,7 @@ func appendFunc(slice *[]string) func(string) error {
func main() {
insecurerand.Seed(time.Now().UnixNano()) // TODO: remove after upgrading to Go 1.20
// TODO-3: set loglist.UserAgent
loglist.UserAgent = fmt.Sprintf("certspotter/%s (%s; %s; %s)", certspotterVersion(), runtime.Version(), runtime.GOOS, runtime.GOARCH)
var flags struct {
batchSize int // TODO-4: respect this option

View File

@ -21,6 +21,8 @@ import (
"time"
)
var UserAgent = "certspotter"
type ModificationToken struct {
etag string
modified time.Time
@ -70,6 +72,7 @@ func FetchIfModified(ctx context.Context, url string, token *ModificationToken)
if err != nil {
return nil, nil, err
}
request.Header.Set("User-Agent", UserAgent)
if token != nil {
token.setRequestHeaders(request)
}