summaryrefslogtreecommitdiff
path: root/cmd/commands.go
diff options
context:
space:
mode:
authorMatthew Holt <mholt@users.noreply.github.com>2019-06-28 19:28:28 -0600
committerMatthew Holt <mholt@users.noreply.github.com>2019-06-28 19:28:28 -0600
commit31ab737bf26deb9315ffedf99a8bb7d43f620700 (patch)
treebec4c5f0ac1b6b5387c2f0d179276fe340b57539 /cmd/commands.go
parenta4bdf249dbfb0f35e0a35dad6a38db371b126800 (diff)
Refactor code related to getting current version
And set version in CertMagic for User-Agent purposes
Diffstat (limited to 'cmd/commands.go')
-rw-r--r--cmd/commands.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/cmd/commands.go b/cmd/commands.go
index 4745af7..3f866d1 100644
--- a/cmd/commands.go
+++ b/cmd/commands.go
@@ -10,8 +10,10 @@ import (
"os"
"os/exec"
"path/filepath"
+ "strings"
"github.com/caddyserver/caddy"
+ "github.com/mholt/certmagic"
"github.com/mitchellh/go-ps"
)
@@ -126,6 +128,11 @@ func cmdRun() (int, error) {
}
}
+ // set a fitting User-Agent for ACME requests
+ goModule := caddy.GoModule()
+ cleanModVersion := strings.TrimPrefix(goModule.Version, "v")
+ certmagic.UserAgent = "Caddy/" + cleanModVersion
+
// start the admin endpoint along with any initial config
err := caddy.StartAdmin(config)
if err != nil {
@@ -180,10 +187,10 @@ func cmdStop() (int, error) {
}
func cmdVersion() (int, error) {
- goModule := getGoBuildModule()
+ goModule := caddy.GoModule()
if goModule.Sum != "" {
// a build with a known version will also have a checksum
- fmt.Printf("%s (%s)\n", goModule.Version, goModule.Sum)
+ fmt.Printf("%s %s\n", goModule.Version, goModule.Sum)
} else {
fmt.Println(goModule.Version)
}