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

Changed cidrhost() to accept negative host number #13765

Merged
merged 1 commit into from
Apr 19, 2017

Conversation

tmshn
Copy link
Contributor

@tmshn tmshn commented Apr 19, 2017

Changed the interpolation function cidrhost().

The expected behavior, which is also demonstrated in the test code, is as follows:
Given CIDR range and a negative number, get IP address from the end of the range.

Say the CIDR range is 168.192.0.0/24.
-1 will gives you 168.192.0.255 (the last address), or -256 will 168.192.0.0. In this sense, giving -257 will be an error because it's out of the range.

num num from end IP
0 256 168.192.0.0
1 255 168.192.0.1
... ... ...
254 2 168.192.0.254
255 1 168.192.0.255

C.f.; apparentlymart/go-cidr#2

Copy link
Contributor

@apparentlymart apparentlymart left a comment

Choose a reason for hiding this comment

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

Looking good... thanks!

@apparentlymart apparentlymart merged commit 86d7c47 into hashicorp:master Apr 19, 2017
@tmshn tmshn deleted the cidrhost-takes-negative branch April 22, 2017 06:03
@ghost
Copy link

ghost commented Apr 13, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 13, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants