Skip to content

Commit

Permalink
bump required version
Browse files Browse the repository at this point in the history
  • Loading branch information
gaissmai committed Jul 30, 2022
1 parent dd92026 commit 7d015ba
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion go.mod
Expand Up @@ -2,4 +2,4 @@ module github.com/gaissmai/iprange

go 1.18

require github.com/gaissmai/extnetip v0.2.0
require github.com/gaissmai/extnetip v0.3.0
2 changes: 2 additions & 0 deletions go.sum
@@ -1,2 +1,4 @@
github.com/gaissmai/extnetip v0.2.0 h1:m9BAcG3RbEyGsWmC6RCBgH7HOttPgeIMZFZsJoqt+30=
github.com/gaissmai/extnetip v0.2.0/go.mod h1:M3NWlyFKaVosQXWXKKeIPK+5VM4U85DahdIqNYX4TK4=
github.com/gaissmai/extnetip v0.3.0 h1:JNCEMbKAb9tE3SthpAmikPVuR2ifyQt5IKt30RyCSxE=
github.com/gaissmai/extnetip v0.3.0/go.mod h1:M3NWlyFKaVosQXWXKKeIPK+5VM4U85DahdIqNYX4TK4=
17 changes: 10 additions & 7 deletions iprange.go
Expand Up @@ -151,7 +151,7 @@ func (r IPRange) Prefixes() []netip.Prefix {
//
// It appends to dst the netip.Prefix entries that covers r.
func (r IPRange) PrefixesAppend(dst []netip.Prefix) []netip.Prefix {
return extnetip.AppendPrefixes(dst, r.first, r.last)
return extnetip.PrefixesAppend(dst, r.first, r.last)
}

// String returns the string form of the IPRange.
Expand Down Expand Up @@ -208,12 +208,15 @@ func Merge(in []IPRange) (out []IPRange) {
case topic.isDisjunctLeft(r):
// disjoint [f...l] [f...l]
out = append(out, r)
case topic.covers(r):
// no-op
continue
case topic.last.Less(r.last):
// partial overlap [f......l]
// [f....l]
// [f....l]
topic.last = r.last
default:
// no-op: covers or equal
panic("unreachable")
}
}

Expand Down Expand Up @@ -254,18 +257,18 @@ func (r IPRange) Remove(in []IPRange) (out []IPRange) {
// left overlap, move cursor
r.first = m.last.Next()
case m.first.Compare(r.first) > 0:
// right overlap, save [r.first, d.first-1)
// right overlap, save [r.first, m.first-1)
out = append(out, IPRange{r.first, m.first.Prev()})
// new r, (d.last, r.last]
// new r first
r.first = m.last.Next()
default:
panic("unreachable")
}
// overflow from d.last.Next()
// test for overflow from last.Next()
if !r.first.IsValid() {
return out
}
// cursor moved behind r.last
// test if cursor moved behind r.last
if r.last.Less(r.first) {
return out
}
Expand Down

0 comments on commit 7d015ba

Please sign in to comment.