Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include version in useragent string, make it readonly #4184

Merged
merged 1 commit into from
Sep 17, 2024

Conversation

HebaruSan
Copy link
Member

@HebaruSan HebaruSan commented Sep 17, 2024

Background

CKAN and NetKAN use a custom useragent string that identifies them uniquely and works well with most web sites (SourceForge's API being a notable exception, see #4172). This can be overridden with the --net-useragent command line option, which we use to mark the Inflator as a bot so it can be excluded from SpaceDock download counts (see #3490).

Motivation

The useragent string format has a place to put a version:

https://deviceatlas.com/blog/list-of-user-agent-strings

Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)
                                   ^^^

... but currently we don't do that. It would be nice if server operators could tell from their logs what versions of CKAN people are using to download.

In addition, the --net-useragent handling is not implemented as well as it could be. The static string Net.UserAgentString is effectively treated as a global variable, written and read freely by whatever assorted random code feels like it, which is bad for reliability, threading, tests, etc. Current versions of vscode rightly raise a warning about this.

Changes

  • Now Net.UserAgentString is readonly and includes Meta.ReleaseVersion in its default value, so web servers will know which CKAN is being used, and so we can do a future SpaceDock enhancement to track this if we feel like it
  • Now the places that used to overwrite Net.UserAgentString instead pass the user's override value through the parameter stack until reaching one of the functions in Net, which are updated to use the override if passed and fall back to Net.UserAgentString otherwise.

@HebaruSan HebaruSan added Enhancement New features or functionality Easy This is easy to fix GUI Issues affecting the interactive GUI Cmdline Issues affecting the command line Core (ckan.dll) Issues affecting the core part of CKAN Netkan Issues affecting the netkan data Network Issues affecting internet connections of CKAN ConsoleUI Issues affecting the interactive console UI labels Sep 17, 2024
@HebaruSan HebaruSan merged commit e8d485c into KSP-CKAN:master Sep 17, 2024
3 checks passed
@HebaruSan HebaruSan deleted the feature/version-in-useragent branch September 17, 2024 23:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Cmdline Issues affecting the command line ConsoleUI Issues affecting the interactive console UI Core (ckan.dll) Issues affecting the core part of CKAN Easy This is easy to fix Enhancement New features or functionality GUI Issues affecting the interactive GUI Netkan Issues affecting the netkan data Network Issues affecting internet connections of CKAN
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant