-
Notifications
You must be signed in to change notification settings - Fork 697
YDB-2321 Add subnet operations in IP UDF #981
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
Merged
Merged
Changes from 13 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
7dfb5a4
Add basic subnet functions in IP UDF
85df3e8
Minor fixes
0624fe8
Small fixes
02cbf0f
Post-merge fixes
7e15c10
Add subnet match
2d15551
Add GetSubnetByMask
df1f7dc
Add & canonize tests
c801994
Add RU docs for subnet ops
avevad e6a9d5f
Add EN docs for subnet ops
avevad 391bbdf
Revert library changes
dd742fb
Add usage clarification
avevad b079e0a
Add usage examples for IP subnet ops
avevad 5e25ff4
Add usage examples for IP subnet ops (RU)
avevad 65d7959
Fix codestyle
2e50767
Remove unnecessary string allocation
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -4,12 +4,16 @@ | |||||
**Список функций** | ||||||
|
||||||
* ```Ip::FromString(String{Flags:AutoMap}) -> String?``` - из человекочитаемого представления в бинарное | ||||||
* ```Ip::SubnetFromString(String{Flags:AutoMap}) -> String?``` - из человекочитаемого представления подсети в бинарное | ||||||
* ```Ip::ToString(String{Flags:AutoMap}) -> String?``` - из бинарного представления в человекочитаемое | ||||||
* ```Ip::ToString(String{Flags:AutoMap}) -> String?``` - из бинарного представления подсети в человекочитаемое | ||||||
* ```Ip::IsIPv4(String?) -> Bool``` | ||||||
* ```Ip::IsIPv6(String?) -> Bool``` | ||||||
* ```Ip::IsEmbeddedIPv4(String?) -> Bool``` | ||||||
* ```Ip::ConvertToIPv6(String{Flags:AutoMap}) -> String``` - IPv6 остается без изменений, а IPv4 становится embedded в IPv6 | ||||||
* ```Ip::GetSubnet(String{Flags:AutoMap}, [Uint8?]) -> String``` - во втором аргументе размер подсети, по умолчанию 24 для IPv4 и 64 для IPv6 | ||||||
* ```Ip::GetSubnetByMask(String{Flags:AutoMap}, String{Flags:AutoMap}) -> String``` - во втором аргументе битовая маска подсети | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
* ```Ip::SubnetMatch(String{Flags:AutoMap}, String{Flags:AutoMap}) -> Bool``` - в первом аргументе подсеть, во втором аргументе подсеть или адрес | ||||||
|
||||||
**Примеры** | ||||||
|
||||||
|
@@ -24,4 +28,18 @@ SELECT | |||||
Ip::FromString("213.180.193.3") | ||||||
) | ||||||
); -- "213.180.193.0" | ||||||
|
||||||
SELECT | ||||||
Ip::SubnetMatch( | ||||||
Ip::SubnetFromString("192.168.0.1/16"), | ||||||
Ip::FromString("192.168.1.14"), | ||||||
); -- true | ||||||
|
||||||
SELECT | ||||||
Ip::ToString( | ||||||
Ip::GetSubnetByMask( | ||||||
Ip::FromString("192.168.0.1"), | ||||||
Ip::FromString("255.255.0.0") | ||||||
) | ||||||
); -- "192.168.0.0" | ||||||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.