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

fix: add helia version to agent version #128

Merged
merged 1 commit into from
May 19, 2023

Conversation

achingbrain
Copy link
Member

If the user has configured identify but not overridden the agent version, add helia and its version number to the string.

Fixes #122

If the user has configured identify but not overidden the agent
version, add helia and its version number to the string.
@achingbrain achingbrain requested a review from a team as a code owner May 19, 2023 16:30
Copy link
Member

@SgtPooki SgtPooki left a comment

Choose a reason for hiding this comment

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

lgtm but confused why we're saving version & name in version.ts instead of version.json or a more aptly named agentInfo.json

Comment on lines +1 to +2
export const version = '0.0.0'
export const name = 'helia'
Copy link
Member

Choose a reason for hiding this comment

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

why not have this file be a json file

Copy link
Member Author

Choose a reason for hiding this comment

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

Node 18 still shows a warning if you import json from js:

(node:25810) ExperimentalWarning: Importing JSON modules is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)

Comment on lines +46 to +47
const agentVersionBuf = peer.metadata.get('AgentVersion')
const agentVersion = new TextDecoder().decode(agentVersionBuf)
Copy link
Member

Choose a reason for hiding this comment

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

does it make sense to maintain and expose a method for obtaining a decoded agent version ? I can imagine having to decode this agent version being a minor pain point for users.

Copy link
Member Author

Choose a reason for hiding this comment

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

The AgentVersion is used by the identify protocol and it's not something people generally interact with directly.

@achingbrain achingbrain merged commit 48e19ec into main May 19, 2023
@achingbrain achingbrain deleted the fix/add-helia-to-agent-version branch May 19, 2023 17:00
github-actions bot pushed a commit that referenced this pull request May 19, 2023
## [@helia/interface-v1.1.1](https://github.com/ipfs/helia/compare/@helia/interface-v1.1.0...@helia/interface-v1.1.1) (2023-05-19)

### Bug Fixes

* add helia version to agent version ([#128](#128)) ([48e19ec](48e19ec)), closes [#122](#122)
@github-actions
Copy link
Contributor

🎉 This PR is included in version @helia/interface-v1.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

github-actions bot pushed a commit that referenced this pull request May 19, 2023
## [helia-v1.1.1](helia-v1.1.0...helia-v1.1.1) (2023-05-19)

### Bug Fixes

* add helia version to agent version ([#128](#128)) ([48e19ec](48e19ec)), closes [#122](#122)
@github-actions
Copy link
Contributor

🎉 This PR is included in version helia-v1.1.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

@BigLep BigLep left a comment

Choose a reason for hiding this comment

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

I know there are tests/aseerts here (great - thanks). For my own learning, could you please paste what the resulting full "versionStr" is that Helia will now be using (and what it was before). (I know I could get things up and running to figure out myself - I'm asking as a time saver for me - thank you!)

Comment on lines +156 to +157
if (versionStr.match(/js-libp2p\/\d+\.\d+\.\d+\sUserAgent=/) == null) {
// the user changed the agent version
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not saying we need to open a new PR, but I think it would be nice in future for these kinds of things if we linked to the source of the information (presumably somewhere in js-libp2p).

Copy link
Member Author

Choose a reason for hiding this comment

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

Agree, but it’s buried fairly deeply in the identify service so would need a change there - it’s not something that’s needed to be accessed before.

@achingbrain
Copy link
Member Author

achingbrain commented May 22, 2023

could you please paste what the resulting full "versionStr" is that Helia will now be using (and what it was before)

Before:

libp2p/x.x.x UserAgent=$USER_AGENT

Where $USER_AGENT is either the current node.js version (e.g. v18.16.0), or the browser's user agent string (e.g. Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36)

After:

helia/x.x.x libp2p/x.x.x UserAgent=$USER_AGENT

@BigLep
Copy link
Contributor

BigLep commented May 22, 2023

Thanks for the info @achingbrain . I added ann FAQ entry: https://github.com/ipfs/helia/wiki/%E2%9D%93-FAQ#-how-does-helia-identify-itself. Please modify if I got anything wrong.

This was referenced Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Helia identifies itself to the network
3 participants