Browse Source

Add support for `%current_version` variable in IMGPROXY_USER_AGENT

DarthSim 1 week ago
parent
commit
1799ac7eb7
2 changed files with 5 additions and 1 deletions
  1. 1 0
      CHANGELOG.md
  2. 4 1
      config/config.go

+ 1 - 0
CHANGELOG.md

@@ -19,6 +19,7 @@
 
 ### Changed
 - Suppress "Response has no supported checksum" warnings from S3 SDK.
+- The [IMGPROXY_USER_AGENT](https://docs.imgproxy.net/latest/configuration/options#IMGPROXY_USER_AGENT) config now supports the `%current_version` variable that is replaced with the current imgproxy version.
 - (docker) Optimized image quantization.
 - (pro) Improved BlurHash generation performance.
 

+ 4 - 1
config/config.go

@@ -8,6 +8,7 @@ import (
 	"os"
 	"regexp"
 	"runtime"
+	"strings"
 
 	log "github.com/sirupsen/logrus"
 
@@ -308,7 +309,7 @@ func Reset() {
 
 	AllowOrigin = ""
 
-	UserAgent = fmt.Sprintf("imgproxy/%s", version.Version)
+	UserAgent = "imgproxy/%current_version"
 
 	IgnoreSslVerification = false
 	DevelopmentErrorsMode = false
@@ -568,6 +569,8 @@ func Configure() error {
 	configurators.String(&AllowOrigin, "IMGPROXY_ALLOW_ORIGIN")
 
 	configurators.String(&UserAgent, "IMGPROXY_USER_AGENT")
+	UserAgent = strings.ReplaceAll(UserAgent, "%current_version", version.Version)
+	fmt.Println("User-Agent:", UserAgent)
 
 	configurators.Bool(&IgnoreSslVerification, "IMGPROXY_IGNORE_SSL_VERIFICATION")
 	configurators.Bool(&DevelopmentErrorsMode, "IMGPROXY_DEVELOPMENT_ERRORS_MODE")