Set User-Agent header when fetching log list
This commit is contained in:
parent
2366c06ca6
commit
2f2ad094db
|
@ -19,11 +19,13 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strings"
|
"strings"
|
||||||
"syscall"
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"software.sslmate.com/src/certspotter/loglist"
|
||||||
"software.sslmate.com/src/certspotter/monitor"
|
"software.sslmate.com/src/certspotter/monitor"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -103,7 +105,7 @@ func appendFunc(slice *[]string) func(string) error {
|
||||||
func main() {
|
func main() {
|
||||||
insecurerand.Seed(time.Now().UnixNano()) // TODO: remove after upgrading to Go 1.20
|
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 {
|
var flags struct {
|
||||||
batchSize int // TODO-4: respect this option
|
batchSize int // TODO-4: respect this option
|
||||||
|
|
|
@ -21,6 +21,8 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var UserAgent = "certspotter"
|
||||||
|
|
||||||
type ModificationToken struct {
|
type ModificationToken struct {
|
||||||
etag string
|
etag string
|
||||||
modified time.Time
|
modified time.Time
|
||||||
|
@ -70,6 +72,7 @@ func FetchIfModified(ctx context.Context, url string, token *ModificationToken)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
|
request.Header.Set("User-Agent", UserAgent)
|
||||||
if token != nil {
|
if token != nil {
|
||||||
token.setRequestHeaders(request)
|
token.setRequestHeaders(request)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue