Skip to content

Commit 19027ab

Browse files
committed
show user which non primary ips are private
the api response doesn't help us a whole lot here, so parsing the range. Realistically, this solution will be good enough for 99% of use cases.
1 parent b3f0c50 commit 19027ab

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

cmd/cloudNetworkPublicList.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ package cmd
1717

1818
import (
1919
"fmt"
20+
"net"
2021

22+
"github.com/spf13/cast"
2123
"github.com/spf13/cobra"
2224

2325
"github.com/liquidweb/liquidweb-cli/instance"
@@ -48,6 +50,7 @@ var cloudNetworkPublicListCmd = &cobra.Command{
4850

4951
fmt.Printf("IP Assignments for %s:\n\n", uniqIdFlag)
5052

53+
_, cloudPrivateSubnet, _ := net.ParseCIDR("10.0.0.0/8")
5154
for c, item := range results.Items {
5255
var details apiTypes.NetworkAssignmentListEntry
5356
if err := instance.CastFieldTypes(item, &details); err != nil {
@@ -58,7 +61,11 @@ var cloudNetworkPublicListCmd = &cobra.Command{
5861
if c == 0 {
5962
fmt.Println("Primary IP:")
6063
} else {
61-
fmt.Println("Secondary IP:")
64+
if cloudPrivateSubnet.Contains(net.ParseIP(cast.ToString(item["ip"]))) {
65+
fmt.Println("Private/Secondary IP:")
66+
} else {
67+
fmt.Println("Secondary IP:")
68+
}
6269
}
6370
fmt.Print(details)
6471
}

0 commit comments

Comments
 (0)