Skip to content

gui, lib/api: Add possibility to feed through extra version information - #8980

Merged
calmh merged 4 commits into
syncthing:mainfrom
calmh:stversionextra
Jul 16, 2023
Merged

calmh merged 4 commits into
syncthing:mainfrom
calmh:stversionextra

Conversation

@calmh

@calmh calmh commented Jul 10, 2023

Copy link
Copy Markdown
Member

This adds an environment variable STVERSIONEXTRA that, when set, gets added to the version information in the API and GUI. In the CLI we see the following:

% STVERSIONEXTRA=foo ./bin/syncthing --version
syncthing v1.23.7-rc.1 (foo) "Fermium Flea" (go1.20.5 darwin...etc

In the GUI it's shown similarly in the About screen and in the local device box.

The purpose of all this is to be able to communicate something about the bundling or packaging, through the log & GUI and the end user, to the potential person supporting it -- i.e., us. :) A wrapper can set this variable to indicate that Syncthing is being run via SyncTrayzor, Syncthing-macOS, etc., and thus indicate to the end user that the GUI they are looking at is perhaps not the only source of truth and management for this instance.

This adds an environment variable STVERSIONEXTRA that, when set, gets
added to the version information in the API and GUI. In the CLI we see the following:

    % STVERSIONEXTRA=foo ./bin/syncthing --version
    syncthing v1.23.7-rc.1 (foo) "Fermium Flea" (go1.20.5 darwin...etc

In the GUI it's shown similarly in the About screen and in the local
device box.

The purpose of all this is to be able to communicate something about the
bundling or packaging, through the log & GUI and the end user, to the
potential person supporting it -- i.e., us. :) A wrapper can set this
variable to indicate that Syncthing is being run via `SyncTrayzor`,
`Syncthing-macOS`, etc., and thus indicate to the end user that the GUI
they are looking at is perhaps not the only source of truth and
management for this instance.

@acolomb acolomb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we sanitize the value somehow, e.g. removing punctuation like parentheses that will make the elaborate version string even more confusing? Allow only alphanumeric, comma, dash and dot for example?

I don't think sanitizing is an issue in the HTML context. If someone wants to inject code via this environment variable, they might just as well use STGUIASSETS.

@calmh

calmh commented Jul 11, 2023

Copy link
Copy Markdown
Member Author

Indeed, that might be an idea. It should be safe in html regardless, but no reason to let the version string become extremely odd.

@calmh

calmh commented Jul 12, 2023 •

Copy link
Copy Markdown
Member Author

So, slight change. In the GUI we can do what we want, and I kept the thing there. The version string is however parsed in places, maybe not only by us, and we can't/shouldn't add random stuff to the middle. We have the tags field at the end that's sort of free-form, so I'm adding it there instead. The effect is the same in logs and CLI (it's visible) while not breaking tooling...

Also added a filter to avoid things that might break the version string.

Comment thread lib/build/build.go
}
)

const versionExtraAllowedChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-. "

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm aware this is not particularly inclusive or culturally sensitive, however I think for the version string it's fine to limit ourselves to basic ASCII.

@acolomb

acolomb commented Jul 12, 2023

Copy link
Copy Markdown
Member

Should we really differentiate between GUI and logs with two different variants of the version string? Are there good reasons or previous examples for that?

Sorry couldn't check the actual difference, just commenting from mobile.

@calmh

calmh commented Jul 13, 2023 •

Copy link
Copy Markdown
Member Author

Yeah I think it's fine. I'll screen shot later when I'm back at a computer, but the formats are already quite different and for different purposes. The text version in logs and --version is kind of all the technical details and in a (by now) locked in format.

The one one the gui just shows the version tag and platform, in a different format than the raw version, e.g. "macOS 64-bit ARM" instead of "darwin-arm64" and also already shows things like "Container" when running in a container. The main purpose (to me) is to show the version running to the user and communicate some basics about the platform to a supporter looking at the screenshot.

Comment thread lib/api/api.go
"version": build.Version,
"codename": build.Codename,
"longVersion": build.LongVersion,
"extra": build.Extra,

@AudriusButkevicius AudriusButkevicius Jul 13, 2023 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't this all be versionExtra instead of just an ambiguous extra?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole thing is the response to /system/version so it should be unambiguous.

@calmh

calmh commented Jul 16, 2023

Copy link
Copy Markdown
Member Author
% STVERSIONEXTRA="calmh-wrapper" ../bin/syncthing -home h2
[start] 2023/07/16 17:41:31 INFO: syncthing v1.23.7-dev.28.g26a389e2-stversionextra "Fermium Flea" (go1.20.6 darwin-arm64) [email protected] 2023-07-12 07:29:39 UTC [calmh-wrapper, purego, stnoupgrade]
[start] 2023/07/16 17:41:32 INFO: No automatic upgrades; STNOUPGRADE environment variable defined.
[MRIW7] 2023/07/16 17:41:32 INFO: My ID: MRIW7OK-NETT3M4-N6SBWME-N25O76W-YJKVXPH-FUMQJ3S-P57B74J-GBITBAC
Screenshot 2023-07-16 at 17 41 42

The whole thing is unpretty right now because the long version with branch name etc but that's not going to be a thing in releases.

@calmh
calmh merged commit df2ac7a into syncthing:main Jul 16, 2023
calmh added a commit to calmh/syncthing that referenced this pull request Jul 16, 2023
calmh added a commit to calmh/syncthing that referenced this pull request Jul 17, 2023
* main: (27 commits)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Mention STVERSIONEXTRA in --help output (ref syncthing#8980)
  gui, lib/api: Add possibility to feed through extra version information (syncthing#8980)
  cmd/ursrv: Update map tile URL
  cmd/strelaypoolsrv: Update map tile URL (syncthing#8985)
  cmd/stcrashreceiver: Correct parsing of current version string
  build: Update dependencies
  cmd/ursrv: Remove old, unused user movement code
  cmd/ursrv: Merge ursrv and uraggregate as subcommands
  cmd/ursrv: Remove useless static TLS cert handling
  cmd/ursrv: Embed static assets
  cmd/ursrv: Refactor to use CLI options, fewer global vars
  gui: Show xattr filter editor when send xattrs checked (fixes syncthing#8958) (syncthing#8959)
  gui, man, authors: Update docs, translations, and contributors
  build: Build Docker image for plain 32 bit arm (fixes syncthing#8973)
  lib/fs: Clarify errors for Windows filenames (fixes syncthing#8968) (syncthing#8969)
  gui: Avoid spurious comma in shared-with device list (fixes syncthing#8967) (syncthing#8970)
  cmd/ursrv: Summarize tiny fraction items into Other
  cmd/ursrv: Update distributions list
  build: Only push releases to cloud storage, and also use `latest`
  ...
calmh added a commit that referenced this pull request Jul 17, 2023
* main: (42 commits)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Mention STVERSIONEXTRA in --help output (ref #8980)
  gui, lib/api: Add possibility to feed through extra version information (#8980)
  cmd/ursrv: Update map tile URL
  cmd/strelaypoolsrv: Update map tile URL (#8985)
  cmd/stcrashreceiver: Correct parsing of current version string
  build: Update dependencies
  cmd/ursrv: Remove old, unused user movement code
  cmd/ursrv: Merge ursrv and uraggregate as subcommands
  cmd/ursrv: Remove useless static TLS cert handling
  cmd/ursrv: Embed static assets
  cmd/ursrv: Refactor to use CLI options, fewer global vars
  gui: Show xattr filter editor when send xattrs checked (fixes #8958) (#8959)
  gui, man, authors: Update docs, translations, and contributors
  build: Build Docker image for plain 32 bit arm (fixes #8973)
  lib/fs: Clarify errors for Windows filenames (fixes #8968) (#8969)
  gui: Avoid spurious comma in shared-with device list (fixes #8967) (#8970)
  cmd/ursrv: Summarize tiny fraction items into Other
  cmd/ursrv: Update distributions list
  build: Only push releases to cloud storage, and also use `latest`
  ...
calmh added a commit to calmh/syncthing that referenced this pull request Jul 25, 2023
* main:
  gui: Remove Twitter link from footer (syncthing#9000)
  gui, man, authors: Update docs, translations, and contributors
  lib/ur: Don't report uptime if start time is in the past (fixes syncthing#7698) (syncthing#8996)
  lib/model: use WARN for "Unexpected folder" messages (syncthing#8998)
  lib/osutil: Skip setLowPriority in Windows if already lower (fixes syncthing#6597) (syncthing#8993)
  all: replace empty slice literal with `var` (syncthing#8990)
  all: fix unused method receiver (syncthing#8988)
  all: unused parameter should be replaced by underscore (syncthing#8989)
  gui, man, authors: Update docs, translations, and contributors
  cmd/syncthing: Mention STVERSIONEXTRA in --help output (ref syncthing#8980)
  gui, lib/api: Add possibility to feed through extra version information (syncthing#8980)
  cmd/ursrv: Update map tile URL
  cmd/strelaypoolsrv: Update map tile URL (syncthing#8985)
  cmd/stcrashreceiver: Correct parsing of current version string
@calmh calmh added this to the v1.23.7 milestone Jul 31, 2023
@calmh
calmh deleted the stversionextra branch September 6, 2023 11:09
@st-review st-review added the frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion label Jul 15, 2024
@syncthing syncthing locked and limited conversation to collaborators Jul 15, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

frozen-due-to-age Issues closed and untouched for a long time, together with being locked for discussion

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants