diff --git a/internal/app/bridge.go b/internal/app/bridge.go index ae09cbbb..7db9af80 100644 --- a/internal/app/bridge.go +++ b/internal/app/bridge.go @@ -34,11 +34,17 @@ func withBridge( cookieJar http.CookieJar, fn func(*bridge.Bridge) error, ) error { + // Get the current bridge version. + version, err := semver.NewVersion(constants.Version) + if err != nil { + return fmt.Errorf("could not create version: %w", err) + } + // Create the underlying dialer used by the bridge. // It only connects to trusted servers and reports any untrusted servers it finds. pinningDialer := dialer.NewPinningTLSDialer( dialer.NewBasicTLSDialer(constants.APIHost), - dialer.NewTLSReporter(constants.APIHost, constants.AppVersion, identifier, dialer.TrustedAPIPins), + dialer.NewTLSReporter(constants.APIHost, constants.AppVersion(version.Original()), identifier, dialer.TrustedAPIPins), dialer.NewTLSPinChecker(dialer.TrustedAPIPins), ) @@ -57,12 +63,6 @@ func withBridge( return fmt.Errorf("could not create updater: %w", err) } - // Get the current bridge version. - version, err := semver.NewVersion(constants.Version) - if err != nil { - return fmt.Errorf("could not create version: %w", err) - } - // Create a new bridge. bridge, err := bridge.New( // The app stuff. diff --git a/internal/bridge/bridge.go b/internal/bridge/bridge.go index 46ac32d5..879c8bbc 100644 --- a/internal/bridge/bridge.go +++ b/internal/bridge/bridge.go @@ -98,7 +98,7 @@ func New( ) (*Bridge, error) { api := liteapi.New( liteapi.WithHostURL(apiURL), - liteapi.WithAppVersion(constants.AppVersion), + liteapi.WithAppVersion(constants.AppVersion(curVersion.Original())), liteapi.WithCookieJar(cookieJar), liteapi.WithTransport(roundTripper), ) diff --git a/internal/constants/constants.go b/internal/constants/constants.go index 9dd6796f..0a0f3c69 100644 --- a/internal/constants/constants.go +++ b/internal/constants/constants.go @@ -45,9 +45,6 @@ var ( // Version of the build. Version = "2.4.1+git" - // AppVersion is the full rendered version of the app (to be used in request headers). - AppVersion = getAPIOS() + cases.Title(language.Und).String(ConfigName) + "_" + Version - // Revision is current hash of the build. Revision = "" @@ -67,6 +64,11 @@ var ( Host = "127.0.0.1" ) +// AppVersion returns the full rendered version of the app (to be used in request headers). +func AppVersion(version string) string { + return getAPIOS() + cases.Title(language.Und).String(ConfigName) + "_" + version +} + func getAPIOS() string { switch runtime.GOOS { case "darwin":