Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Add IP range input support (ipv4, ipv6) #98 - Update main.go to accept IP range from stdin and print the possible CIDRs * Add test cases to validate RangeTOCIDR function - Add test case for singleCIDR, multipleCIDRs and ip6 range. - Convert the []net.IPNet to []string before comparing the expected. * Add check to validate the IP range and Update README - Accept the list of IP ranges - Fatal() if the first IP is greater than last IP - Fatal() if IP range contains more than 2 values. - Update README.md to add the ip range input documentation. * Update IP range functionality to accept only single range - Remove the unnecessary for loop. - Update the READ.md to remove the IP range list block * Remove the IP comparing logic to a function - Add new function `GetCIDRFromIPRange` which validate the input If input is wrong send the error otherwise returns the sorted list of CIDR ranges. - Update the test case to test `GetCIDRFromIPRange` function. - Add the wrong input IP range test case. - Remove the IP comparing and sorting logic from main.go * Remove the typo * Update code to handle the IP range expansion - Update the `main.go` to handle the case to IP range expansion - rename the `CIDRFromIPRange` to `IPRangeInput` - Add the if block which handles the case when Input is IP range. * Remove old cidrs before appending new cidrs in allCidrs * Move logic to common function to avoid repetition. Do not overwrite allCidrs list instead use a separate net.IP list. * Add tests for process function, * Break wg.Add(2) into two wg.Add(1) * Make wg.Done as defer * Handle case of multiple IP range, combination of CIDR and IP range - Input may contain the multiple CIDRs and multiple IP ranges eg. `166.8.0.0/16,166.11.0.0/16,166.9.0.0-166.10.255.255` - Handle the above input for arggregation, count, etc - Move the string split logic from `main()` to `process()` function - Add the new variable IPRangeMap which stores multiple IP range * Add the comment for ipRange block * Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. Replace ipRangeMap to ipRangeList. - map key is not being used so dropped the map implementation. * Resolve the requested changes - Remove the IPRangeInput variable - Simplify checking len of IPRange Input - Use require package for checking expected and got in test cases * Replace string.Equal to require package for testing * Update goflags version - mapcidr and goflag had conflicting version to solve that update the goflags version * Update sorting behaviour - Expand the CIDR then sort - Before it was converting IPs to CIDR then sort. - Add `getIPList()` which expands the CIDRs to IP for sorting * Remove the unnecessary err block Co-authored-by: Sandeep Singh <[email protected]> Co-authored-by: Jaideep Khandelwal <[email protected]> Co-authored-by: Siddharth Shashikar <[email protected]>
- Loading branch information