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

multi: Rework client user agent id logic. #415

Merged

Conversation

davecgh
Copy link
Member

@davecgh davecgh commented Oct 14, 2023

This reworks the client user agent identification logic to improve its efficiency and flexibility as well as to easily support old minor versions.

It does this by changing the matching logic to first parse the user agent into its individual components and then attempting to match against that parsed information using matching functions as opposed to encoding the more specific matching logic directly into a regular expression.

The user agent parsing first attempts to split it into a client name and version part and when that is successful further attempts to parse the version part into the individual semantic version components using a regular expression with capture groups.

The matching functions are closures that accept the parsed user agent details and may impose arbitrary criteria.

For convenience a default matching function is added that requires the user agent to have a provided client name and major version as well as a minor version that is less than or equal to specified value.

The user agent matching tests are updated accordingly.

Finally, decred-gominer is updated to support up to version 2.1.x so the pool will work with both version 2.0.0 as well as the master branch that will be moving to version 2.1.0-pre for ongoing development.

Copy link
Member

@jholdstock jholdstock left a comment

Choose a reason for hiding this comment

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

Looks good other than comment typo

internal/semver/semver_test.go Outdated Show resolved Hide resolved
This moves the semver parsing code into an internal package and adds
tests to ensure proper functionality.

The primary motiviation is to make it available for reuse in other
packages such as the pool package.
This reworks the client user agent identification logic to improve its
efficiency and flexibility as well as to easily support old minor
versions.

It does this by changing the matching logic to first parse the user
agent into its individual components and then attempting to match
against that parsed information using matching functions as opposed to
encoding the more specific matching logic directly into a regular
expression.

The user agent parsing first attempts to split it into a client name and
version part and when that is successful further attempts to parse the
version part into the individual semantic version components using a
regular expression with capture groups.

The matching functions are closures that accept the parsed user agent
details and may impose arbitrary criteria.

For convenience a default matching function is added that requires the
user agent to have a provided client name and major version as well as a
minor version that is less than or equal to specified value.

The user agent matching tests are updated accordingly.

Finally, `decred-gominer` is updated to support up to version 2.1.x so
the pool will work with both version 2.0.0 as well as the master branch
that will be moving to version 2.1.0-pre for ongoing development.
@davecgh davecgh force-pushed the multi_rework_client_ua_identification branch from de27a7e to e3e3d22 Compare October 18, 2023 07:01
@jholdstock jholdstock merged commit f1be8b1 into decred:master Oct 18, 2023
2 checks passed
@davecgh davecgh deleted the multi_rework_client_ua_identification branch October 18, 2023 07:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants