@marcel91200 / caddy Mirror · read-only / commits / 0b3161ae
Fork 0

Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS

Mirrored from https://github.com/Slazee/caddy.git

Synced Nov 13, 13:00 UTC

cmd: Customizable user agent (close #2795)

Matthew Holt committed Sep 13, 2022 at 17:21 UTC 0b3161aeea388a092fd5a128191d64e7fd2fd941
1 file changed +7 -2
cmd/main.go
+7 -2
@@ -41,10 +41,15 @@ func init() {
41 // set a fitting User-Agent for ACME requests
42 version, _ := caddy.Version()
43 cleanModVersion := strings.TrimPrefix(version, "v")
44 - certmagic.UserAgent = "Caddy/" + cleanModVersion
44 + ua := "Caddy/" + cleanModVersion
45 + if uaEnv, ok := os.LookupEnv("USERAGENT"); ok {
46 + ua = uaEnv + " " + ua
47 + }
48 + certmagic.UserAgent = ua
49
50 // by using Caddy, user indicates agreement to CA terms
47 - // (very important, or ACME account creation will fail!)
51 + // (very important, as Caddy is often non-interactive
52 + // and thus ACME account creation will fail!)
53 certmagic.DefaultACME.Agreed = true
54 }
55