Skip to content

API proposal: Mask testing for IPAddress #42845

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

Closed
huoyaoyuan opened this issue Sep 29, 2020 · 11 comments
Closed

API proposal: Mask testing for IPAddress #42845

huoyaoyuan opened this issue Sep 29, 2020 · 11 comments
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net needs-author-action An issue or pull request that requires more info or actions from the author.
Milestone

Comments

@huoyaoyuan
Copy link
Member

Background and Motivation

From #42840
A weird workaround is used for mask testing. Masking should be exposed as a direct concept for ip addresses.

Proposed API

namespace System.Net
{
    public class IPAddress
    {
+        public bool IsMask(IPAddress address, int maskLength);
    }
}

Usage Examples

var mask = IPAddress.Parse("192.168.0.0");
var address = IPAddress.Parse("192.168.1.1");
Assert.True(mask.IsMask(address, 16));

Alternative Designs

Expose a separated IPAddressMask type? Then mask length doesn't needed to be passed in every call.

Risks

Is storing masks violating the IPAddress type? If so, an IPAddressMask type should be appropriate.

@huoyaoyuan huoyaoyuan added the api-suggestion Early API idea and discussion, it is NOT ready for implementation label Sep 29, 2020
@Dotnet-GitSync-Bot Dotnet-GitSync-Bot added the untriaged New issue has not been triaged by the area owner label Sep 29, 2020
@Dotnet-GitSync-Bot
Copy link
Collaborator

I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label.

@ghost
Copy link

ghost commented Sep 30, 2020

Tagging subscribers to this area: @dotnet/ncl
See info in area-owners.md if you want to be subscribed.

@scalablecory
Copy link
Contributor

Would this check if an IPAddress is exactly equal to a mask, or only that the IP address is within the mask?

@wfurt
Copy link
Member

wfurt commented Oct 1, 2020

note that mask operations are obsolete in IPv6. There was similar CIDR proposal which did not fly.

@karelz karelz added this to the Future milestone Oct 2, 2020
@karelz karelz added needs more info and removed untriaged New issue has not been triaged by the area owner labels Oct 2, 2020
@karelz
Copy link
Member

karelz commented Oct 2, 2020

Given that this is IPv4 only feature and the world is moving towards IPv6, I wonder if this makes sense at all ... should we just close it as Won't Fix?

@ghost ghost added the no-recent-activity label Dec 7, 2020
@dotnet dotnet deleted a comment Dec 7, 2020
@ghost ghost removed the no-recent-activity label Dec 7, 2020
@alrz
Copy link
Member

alrz commented Jan 13, 2022

Does a IPAddressRange API fit into this bucket? There's https://www.nuget.org/packages/IPAddressRange with horrendous impl that I wouldn't want to use.

@MihaZupan
Copy link
Member

Have you considered contributing a better implementation that would be acceptable?

@alrz
Copy link
Member

alrz commented Jan 13, 2022

That's a complete rewrite. I did implement a simple one just to use Contains - no parsing or validation though.

@antonfirsov
Copy link
Member

Unless there are valid concerns, I recommend to close this in favor of #79946.

@antonfirsov antonfirsov added the needs-author-action An issue or pull request that requires more info or actions from the author. label Jan 18, 2023
@ghost
Copy link

ghost commented Jan 18, 2023

This issue has been marked needs-author-action and may be missing some important information.

@huoyaoyuan
Copy link
Member Author

Agreed to close in favor of #79946.

@huoyaoyuan huoyaoyuan closed this as not planned Won't fix, can't repro, duplicate, stale Jan 19, 2023
@ghost ghost locked as resolved and limited conversation to collaborators Feb 18, 2023
@karelz karelz modified the milestones: Future, 8.0.0 Mar 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api-suggestion Early API idea and discussion, it is NOT ready for implementation area-System.Net needs-author-action An issue or pull request that requires more info or actions from the author.
Projects
None yet
Development

No branches or pull requests

9 participants