Conversation
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Test Results3 506 tests +26 3 502 ✅ +26 1m 51s ⏱️ +9s Results for commit b87f9db. ± Comparison against base commit ae0f3a3. This pull request removes 1 and adds 27 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
| bytes address = 1; | ||
| bool has_prefix = 2; | ||
| int32 prefix_length = 3; | ||
| } No newline at end of file |
| var bitmasks = []byte{0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff} | ||
|
|
||
| func int2ip(i int64) string { | ||
| func int2ip[T int | int64 | int32 | uint | uint64 | uint32](i T) net.IP { |
There was a problem hiding this comment.
Just a question since I see in MQL we use int64 everywhere. It looks awesome but I'm curious if we are even using all of those types? 🤔
There was a problem hiding this comment.
yeah tbh I just went over-eager here 😁 If I'm honest, we only need int and int64, just like the other method
| return t, true | ||
| case string: | ||
| return ParseIP(t), true | ||
| case int64: |
There was a problem hiding this comment.
are we missing some types here? like int and others? 🤔
There was a problem hiding this comment.
I'm guessing no, but if so, we won't ever use the other types, I think.
There was a problem hiding this comment.
Not at this position, because the internal values can only be these 3, ie for int it can only be an int64. Much of the backend is built around this.
| var bitmasks = []byte{0x00, 0x80, 0xc0, 0xe0, 0xf0, 0xf8, 0xfc, 0xfe, 0xff} | ||
|
|
||
| func int2ip(i int64) string { | ||
| func int2ip[T int | int64 | int32 | uint | uint64 | uint32](i T) net.IP { |
There was a problem hiding this comment.
Just a question since I see in MQL we use int64 everywhere. It looks awesome but I'm curious if we are even using all of those types? 🤔
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>
Signed-off-by: Dominik Richter <dominik.richter@gmail.com>

Adds the
addressfield, which only returns the address itself:Adds the
cidrfield, which returns the CIDR notation of the IP address. We fill in the prefix length for IPv4 class A/B/C networks and IPv6 automatically:internal:
The bigger thing this PR does is overhaul the internal data structure for IP so we don't have to constantly parse it again. This increases efficiency but also means we have to take care of serialization/deserialization.
Maskwas renamed toPrefixLengthbecause that's what it actually isNewIPis really aParseIPwhich also separates it fromParseIntIP(which is demonstrated above)Why proto-based marshaling?
Not an easy decision, but one that is more maintainable while the interface still shakes out. A byte-optimized marshaling approach will be added later as an alternative.