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

Normalize IPv6 used in Endpoint.equivalent #3428

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

pepone
Copy link
Member

@pepone pepone commented Jan 25, 2025

C# and C++, Java was already done see #3154.

I don't think we need to update JavaScript,

  • This fix is required for collocated calls which are not supported in JavaScript
  • We don't do any IP address manipulation in JavaScript just pass the address directly into the WebSocket.

@pepone pepone requested a review from bernardnormier January 25, 2025 19:43
@pepone pepone changed the title C# - normalize IPv6 used in Endpoint.equivalent Normalize IPv6 used in Endpoint.equivalent Jan 25, 2025
@@ -1610,6 +1610,27 @@ IceInternal::getNumericAddress(const std::string& address)
}
}

string
IceInternal::normalizeIPv6Address(string_view host)
Copy link
Member

Choose a reason for hiding this comment

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

I would use a const string& for host since you give it to inet_pton that expects a null-terminated C-string.

@@ -117,7 +120,7 @@ public override bool equivalent(EndpointI endpoint)
}
IPEndpointI ipEndpointI = (IPEndpointI)endpoint;
return ipEndpointI.type() == type() &&
ipEndpointI.host_.Equals(host_, StringComparison.Ordinal) &&
ipEndpointI._normalizedHost.Equals(_normalizedHost, StringComparison.Ordinal) &&
Copy link
Member

Choose a reason for hiding this comment

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

I would use operator== to compare these strings.

See https://learn.microsoft.com/en-us/dotnet/csharp/how-to/compare-strings.

Copy link
Member Author

Choose a reason for hiding this comment

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

Make the intent of your code clear by calling an overload that explicitly specifies the type of comparison to perform.

Isn't that what we do here? Afaik there is a linter rule for this.

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