Skip to content

Improve error when connecting with an unsupported version - #1482

Merged
Ralith merged 1 commit into
mainfrom
better-version-error
Jan 25, 2023
Merged

Improve error when connecting with an unsupported version#1482
Ralith merged 1 commit into
mainfrom
better-version-error

Conversation

@Ralith

@Ralith Ralith commented Jan 24, 2023

Copy link
Copy Markdown
Collaborator

If the cryptographic layer supports a version not in the local endpoint's supported versions list, a connection was initiated but all packets returned by a compatible peer were dropped. This is a relatively easy configuration error to make.

Fixes #1481.

djc
djc previously approved these changes Jan 24, 2023
if remote.port() == 0 || remote.ip().is_unspecified() {
return Err(ConnectError::InvalidRemoteAddress(remote));
}
if !self.config.supported_versions.contains(&config.version) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Style nit: I think else if would make sense here?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The current pattern is consistent with the two existing checks. I also generally like how it makes them syntactically independent.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Fair enough. I prefer the increased density over syntactic independence, I think. Also in my mind using else if would group these more as a set of preconditions, whereas the syntactic independence means I have to do more work parsing in my head because I consider each of them independently.

Anyway, either is fine.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

(needs reapproval though)

If the cryptographic layer supports a version not in the local
endpoint's supported versions list, a connection could have been
initiated with that version for which all packets returned by a
compatible peer would hav ebeendropped. This is a relatively easy
configuration error to make.
@Ralith
Ralith force-pushed the better-version-error branch from bbb6fb4 to 6776354 Compare January 24, 2023 21:52
@Ralith
Ralith enabled auto-merge (rebase) January 24, 2023 22:17
@Ralith
Ralith merged commit d00a71c into main Jan 25, 2023
@Ralith
Ralith deleted the better-version-error branch January 25, 2023 06:06
@djc djc mentioned this pull request May 8, 2023
3 tasks
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.

The custom version of the api is weird

2 participants