Skip to content

Commit

Permalink
Merge pull request #4 from planetscale/export-main-struct
Browse files Browse the repository at this point in the history
export CloudRanger struct
  • Loading branch information
joemiller authored Nov 26, 2023
2 parents eb46f80 + 5fb28fa commit 1df3794
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions ranger.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/infobloxopen/go-trees/iptree"
)

type cloudRanger struct {
type CloudRanger struct {
tree *iptree.Tree
}

Expand All @@ -17,19 +17,19 @@ type IPInfo struct {
}

// New returns a new cloudRanger.
func New() *cloudRanger {
func New() *CloudRanger {
tree := iptree.NewTree()
for _, r := range cloudRanges {
tree.InplaceInsertNet(r.net, r.info)
}
return &cloudRanger{
return &CloudRanger{
tree: tree,
}
}

// GetIP returns the IPInfo for the given IP address. If the IP address is not
// found in any of the known cloud providers the second return value is false.
func (cr *cloudRanger) GetIP(ip string) (IPInfo, bool) {
func (cr *CloudRanger) GetIP(ip string) (IPInfo, bool) {
addr := net.ParseIP(ip)
if addr == nil {
return IPInfo{}, false
Expand Down

0 comments on commit 1df3794

Please sign in to comment.