mirror of
https://github.com/superseriousbusiness/gotosocial.git
synced 2024-12-22 18:22:11 +00:00
[chore] Simplify the User-Agent string (#2645)
* [chore] Simplify the User-Agent string RFC 9110[1] includes a definition for the format of a user-agent header: User-Agent = product *( RWS ( product / comment ) ) product = token ["/" product-version] product-version = token comment = "(" *( ctext / quoted-pair / comment ) ")" ctext = HTAB / SP / %x21-27 / %x2A-5B / %x5D-7E / obs-text An example given in the RFC: User-Agent: CERN-LineMode/2.15 libwww/2.17b3 The idea is typically start with the most important product/version, add a (comment) if necessary and then include any auxilliary products. However, the RFC warns against including too many auxiliary products as those can be unnecessarily revealing. For automated systems (i.e not a browser), the common and recommended format is <product></version> (+uri-for-contact), followed with any additional <product>/<version> pairs that are relevant. This changes our UA to match that convention more closely. This makes it easier for administrators who do user-agent parsing for statistics or other purposes to correctly identify the version of GoToSocial. Currently tools tend to get confused by the lack of a /<version> on the start of our string. [1]: https://www.rfc-editor.org/rfc/rfc9110.html#name-user-agents * [chore] Don't use app name in UA From all the GtS UAs I've collected, nobody seems to set/change this, so we might as well use the static string. The main usefulness for this is when you have multilpe GtS instances connecting to the same DB, so they can identify as different instances by changing the application name (though it should already be obvious from having different usernames).
This commit is contained in:
parent
8b8211986e
commit
a41e8a95bf
|
@ -58,7 +58,6 @@ type controller struct {
|
|||
// NewController returns an implementation of the Controller interface for creating new transports
|
||||
func NewController(state *state.State, federatingDB federatingdb.DB, clock pub.Clock, client httpclient.SigningClient) Controller {
|
||||
var (
|
||||
applicationName = config.GetApplicationName()
|
||||
host = config.GetHost()
|
||||
proto = config.GetProtocol()
|
||||
version = config.GetSoftwareVersion()
|
||||
|
@ -77,7 +76,7 @@ func NewController(state *state.State, federatingDB federatingdb.DB, clock pub.C
|
|||
clock: clock,
|
||||
client: client,
|
||||
trspCache: cache.NewTTL[string, *transport](0, 100, 0),
|
||||
userAgent: fmt.Sprintf("%s (+%s://%s) gotosocial/%s", applicationName, proto, host, version),
|
||||
userAgent: fmt.Sprintf("gotosocial/%s (+%s://%s)", version, proto, host),
|
||||
senders: senders,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue