Send helpful User-Agent string with all requests

This commit is contained in:
Andrew Ayer 2025-06-23 16:32:19 -04:00
parent 187aed078c
commit a4048f47f8
3 changed files with 6 additions and 2 deletions

View File

@ -25,6 +25,7 @@ import (
"syscall"
"time"
"software.sslmate.com/src/certspotter/ctclient"
"software.sslmate.com/src/certspotter/loglist"
"software.sslmate.com/src/certspotter/monitor"
)
@ -139,6 +140,7 @@ func appendFunc(slice *[]string) func(string) error {
func main() {
loglist.UserAgent = fmt.Sprintf("certspotter/%s (%s; %s; %s)", certspotterVersion(), runtime.Version(), runtime.GOOS, runtime.GOARCH)
ctclient.UserAgent = fmt.Sprintf("certspotter/%s (+https://github.com/SSLMate/certspotter)", certspotterVersion())
var flags struct {
batchSize bool

View File

@ -24,6 +24,8 @@ import (
"time"
)
var UserAgent = "software.sslmate.com/src/certspotter"
// Create an HTTP client suitable for communicating with CT logs. dialContext, if non-nil, is used for dialing.
func NewHTTPClient(dialContext func(context.Context, string, string) (net.Conn, error)) *http.Client {
return &http.Client{
@ -61,7 +63,7 @@ func get(ctx context.Context, httpClient *http.Client, fullURL string) ([]byte,
if err != nil {
return nil, err
}
request.Header.Set("User-Agent", "") // Don't send a User-Agent to make life harder for malicious logs
request.Header.Set("User-Agent", UserAgent)
if httpClient == nil {
httpClient = defaultHTTPClient

View File

@ -21,7 +21,7 @@ import (
"time"
)
var UserAgent = "certspotter"
var UserAgent = "software.sslmate.com/src/certspotter"
type ModificationToken struct {
etag string