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

Ability to configure neutrino useragent #4353

Merged
merged 3 commits into from
Sep 23, 2020

Conversation

mrfelton
Copy link
Contributor

@mrfelton mrfelton commented Jun 4, 2020

This PR adds the ability to alter the neutrino useragent string so that neutrino clients can identify themselves as they please.

It exposes the neutrino UserAgentVersion and UserAgentName config options which can be set by starting lnd with the --neutrino.useragentversion= and --neutrino.useragentname= flags.

This enables btcd nodes to better identify connecting clients. For example, it could be used in conjunction with btcd's agentblacklist and agentwhitelist settings to ensure that only clients that identify themselves in a specific way are allowed to connect.

mrfelton added 2 commits June 4, 2020 13:10
Expose the neutrino `UserAgentName` config option. This can be set by
starting lnd with the `--neutrino.useragentname=` flag.
Expose the neutrino `UserAgentVersion` config option. This can be set
by starting lnd with the `--neutrino.useragentversion=` flag.
@Roasbeef Roasbeef added enhancement Improvements to existing features / behaviour neutrino Lightweight neutrino backend-type p2p Code related to the peer-to-peer behaviour labels Jun 4, 2020
@Roasbeef Roasbeef requested a review from wpaulino August 12, 2020 01:57
@Roasbeef Roasbeef added this to the 0.12.0 milestone Aug 12, 2020
@Roasbeef Roasbeef added the v0.12 label Aug 12, 2020
@@ -785,6 +785,7 @@ func initNeutrinoBackend(cfg *Config, chainDir string) (*neutrino.ChainService,

neutrino.MaxPeers = 8
neutrino.BanDuration = time.Hour * 48
neutrino.UserAgentName = cfg.NeutrinoMode.UserAgentName
Copy link
Contributor

Choose a reason for hiding this comment

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

just noting: it would be best to avoid overwriting global variables in the package, but given we already do that above that is out of scope for this PR :)

however, currently neutrino.UserAgentName defaults to "neutrino". if the user doesn't set --neutrino.useragentname then this will be set to an empty string. we can fix this by setting a default value on lncfg.Neutrino, similar to what is done for bitcoind and btcd subconfigs. this default can simply be neutrino.UserAgentName since it'll be read before being overwritten here. the same comment applies to the next commit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added a new commit that sets these default values.

@Roasbeef
Copy link
Member

So do we want to block on fixing that issue, or is this g2g?

@wpaulino
Copy link
Contributor

So do we want to block on fixing that issue, or is this g2g?

It should be a simple fix. I can pick it up if @mrfelton is unable to continue.

@mrfelton mrfelton force-pushed the feat/neutrino-user-agent branch from b6f630a to 51a5137 Compare September 18, 2020 12:18
Copy link
Contributor

@cfromknecht cfromknecht left a comment

Choose a reason for hiding this comment

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

LGTM 🏅 thanks @mrfelton!

@cfromknecht
Copy link
Contributor

@Roasbeef the primary comment has been addressed. longer term we should figure out a solution in the neutrino repo for modifying these values without overwriting globals

@cfromknecht cfromknecht merged commit e135047 into lightningnetwork:master Sep 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements to existing features / behaviour neutrino Lightweight neutrino backend-type p2p Code related to the peer-to-peer behaviour v0.12
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants